uppy/examples/aws-nodejs
github-actions[bot] e47a7e9c21
Release: uppy@4.0.0-beta.8 (#5189)
| Package              |      Version | Package              |      Version |
| -------------------- | ------------ | -------------------- | ------------ |
| @uppy/aws-s3         | 4.0.0-beta.4 | @uppy/status-bar     | 4.0.0-beta.8 |
| @uppy/companion      | 5.0.0-beta.7 | @uppy/svelte         | 4.0.0-beta.4 |
| @uppy/compressor     | 2.0.0-beta.8 | @uppy/tus            | 4.0.0-beta.5 |
| @uppy/core           | 4.0.0-beta.8 | @uppy/utils          | 6.0.0-beta.7 |
| @uppy/dashboard      | 4.0.0-beta.8 | @uppy/vue            | 2.0.0-beta.3 |
| @uppy/image-editor   | 3.0.0-beta.5 | @uppy/webcam         | 4.0.0-beta.7 |
| @uppy/provider-views | 4.0.0-beta.6 | uppy                 | 4.0.0-beta.8 |

- @uppy/core: resolve some (breaking) TODOs (Antoine du Hamel / #4824)
- @uppy/companion: encode `uploadId` (Mikael Finstad / #5168)
- @uppy/companion: bump `express-session` (Antoine du Hamel / #5177)
- @uppy/companion: remove dependency on `express-request-id` (Antoine du Hamel / #5176)
- @uppy/companion: bump prom to v15 (Antoine du Hamel / #5175)
- docs: fix linter (Antoine du Hamel)
- meta: remove `nodemon` from the deps (Antoine du Hamel / #5172)
- docs: update `@uppy/aws-s3` docs (Antoine du Hamel / #5093)
- meta: update more dependencies (Antoine du Hamel / #5171)
- @uppy/companion: upgrade deps (Antoine du Hamel / #5119)
2024-05-22 08:14:30 +00:00
..
public Release: uppy@4.0.0-beta.8 (#5189) 2024-05-22 08:14:30 +00:00
index.js examples/aws: client-side signing (#4463) 2023-07-20 11:34:22 +02:00
package.json Release: uppy@4.0.0-beta.1 (#5047) 2024-03-28 14:00:30 +00: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.