File Uploads

You can upload files via the React form using an input prop of file. The file component supports multiple file uploads using a drag & drop interface.
Uploads are handled on the server using multer and stored in the /uploads directory.
There is a utility API endpoint you can use for uploading files.
When using this endpoint, a temp file will be stored in the /uploads folder by multer. The controller will then upload this file to S3. You will need to specify the bucket name.
Alternatively, if you want to upload a file to another endpoint you'll need to use the multer middleware in the same manner as the utility endpoint.
const multer = require('multer');
const upload = multer({ dest: 'uploads' });'/api/utility/upload', upload.any(), use(utilityController.upload));

Uploading Files to Amazon S3

Gravity includes a model for interacting with S3, so you can manage your S3 buckets and files in a few lines of code.
// list the buckets
await s3.bucket();
// list the items in the bucket
await s3.bucket.items(bucketName);
// create a new bucket
await s3.bucket.create(bucketName);
// delete a bucket
await s3.bucket.delete(bucketName);
// upload a file
await s3.upload({ bucketName, file });
// delete a file
await s3.delete({ bucketName, file });
// get a signed url for a file
await s3.signedURL({ bucketName, fileName, expires, acl });