This example demonstrates how to upload a file directly to S3 from a browser. The Node server generates a policy and signature, authorizing the upload.
Once a file has been successfully uploaded, S3 redirects the browser to a Node callback url.
To get started:
npm install
export AWS_KEY='your-aws-key'
export AWS_SECRET='your-key-secret'
export S3_BUCKET='your-bucket-name'
node app.js
Files are uploaded into example/{{uuid}}/filename.ext. By default, S3
will serve uploaded files as application/octet-stream
. Pass a
contentType
parameter to choose a more specific type. For example:
open http://localhost:3000/?contentType=text/html
The policy generated for the upload allows any content type, so the
Content-Type
could also be set client side.