uppy/examples/aws-nodejs
github-actions[bot] 6479159768
Release: uppy@3.16.0 (#4685)
| Package            | Version | Package            | Version |
| ------------------ | ------- | ------------------ | ------- |
| @uppy/companion    |   4.9.0 | @uppy/locales      |   3.3.1 |
| @uppy/compressor   |   1.0.3 | @uppy/tus          |   3.3.0 |
| @uppy/dashboard    |   3.5.3 | uppy               |  3.16.0 |
| @uppy/image-editor |   2.2.0 |                    |         |

- @uppy/tus: Fix: Utilize user-defined onSuccess, onError, and onProgress callbacks in @uppy/tus (choi sung keun / #4674)
- @uppy/dashboard: Make file-editor:cancel event fire when the Image Editor “cancel” button is pressed (Artur Paikin / #4684)
- @uppy/companion: add missing credentialsURL for box (Mikael Finstad / #4681)
- @uppy/companion: remove s3 endpoints if s3 disabled (Mikael Finstad / #4675)
- meta: use latest Node.js version for tests (Antoine du Hamel / #4662)
- meta: Improve Contributing.md (Evgenia Karunus / #4633)
- @uppy/compressor: update file.meta.name after compression, becase format/extension might have changed (Artur Paikin / #4645)
- @uppy/companion: Onedrive refresh tokens (Mikael Finstad / #4655)
- @uppy/companion: catch "invalid initialization vector" instead of crashing (Mikael Finstad / #4661)
- @uppy/image-editor: Improve image rotation (Evgenia Karunus / #4639)
- @uppy/locales: Feature/updating i18n farsi (Parsa Arvaneh / #4638)
2023-09-18 20:12:54 +00:00
..
public Release: uppy@3.16.0 (#4685) 2023-09-18 20:12:54 +00:00
index.js examples/aws: client-side signing (#4463) 2023-07-20 11:34:22 +02:00
package.json examples/aws: client-side signing (#4463) 2023-07-20 11:34:22 +02:00
README.md examples/aws-nodejs: update README (#4534) 2023-06-28 10:52:41 +02:00

Uppy + AWS S3 with Node.JS

A simple and fully working example of Uppy and AWS S3 storage with Node.js (and Express.js). It uses presigned URL at the backend level.

AWS Configuration

It's assumed that you are familiar with AWS, at least, with the storage service (S3) and users & policies (IAM).

These instructions are not fit for production but tightening the security is out of the scope here.

S3 Setup

  • Create new S3 bucket in AWS (e.g. aws-nodejs).

  • Add a bucket policy.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "PublicAccess",
          "Effect": "Allow",
          "Principal": "*",
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::aws-nodejs/*"
        }
      ]
    }
    
  • Make the S3 bucket public.

  • Add CORS configuration.

    [
      {
        "AllowedHeaders": ["*"],
        "AllowedMethods": ["GET", "PUT", "HEAD", "POST", "DELETE"],
        "AllowedOrigins": ["*"],
        "ExposeHeaders": []
      }
    ]
    

AWS Credentials

You may use existing AWS credentials or create a new user in the IAM page.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": ["s3:PutObject", "s3:PutObjectAcl"],
      "Resource": "arn:aws:s3:::aws-nodejs/*"
    }
  ]
}

Prerequisites

Download this code or clone repository into a folder and install dependencies:

CYPRESS_INSTALL_BINARY=0 corepack yarn install

Add a .env file to the root directory and define the S3 bucket name and port variables like the example below:

COMPANION_AWS_BUCKET=aws-nodejs
COMPANION_AWS_REGION=…
COMPANION_AWS_KEY=…
COMPANION_AWS_SECRET=…
PORT=8080

N.B.: This example uses COMPANION_AWS_ environnement variables to facilitate integrations with other examples in this repository, but this example does not uses Companion at all.

Enjoy it

Start the application:

corepack yarn workspace @uppy-example/aws-nodejs start

Dashboard demo should now be available at http://localhost:8080.

You have also a Drag & Drop demo on http://localhost:8080/drag.

Feel free to check how the demo works and feel free to open an issue.