Upload files to AWS S3

This example shows you how to implement a smart action to upload image files to an AWS S3 bucket. Here we have a companies model that has two fields corresponding to files stored in an AWS S3 bucket:

  • A certificate of incorporation

  • A proof of identity

We implemented a smart action to upload the files for each company.

Requirements

  • An admin backend running on forest-express-sequelize

  • An AWS S3 bucket with access credentials

  • The aws-sdk npm package

  • The bluebird npm package

  • The parse-data-uri npm package

How it works

Directory: /models

This directory contains the companies.js file where the companies model is declared.

Directory: /forest

This directory contains the companies.js file where the smart action Upload Legal Docs is declared.

You need to specify that the widget file picker is applicable to the input field used to upload the file.

Directory: /services

This directory contains an s3-helper.js file where the methods to upload files to s3 is declared.

You need to configure your AWS credentials inside your app to get access to your bucket. You can read more about it in the AWS documentation here.

Directory: /routes

This directory contains the companies.js file where the logic of the smart action is implemented.

Last updated

Was this helpful?