Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements the ability to POST uploads #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonathanberube-zylo
Copy link

This PR adds a backwards compatible mechanism to allow for POST uploads.

See a tutorial for how to implement the server, but the gist is replace the existing getSignedUrl call with createPresignedPost. For example:

const data = s3.createPresignedPost({
  Bucket: process.env.BUCKETNAME,
  Fields: {
    key: getRandomFilename(), // totally random
  },
  Conditions: [
    ["content-length-range",   0, 1000000], // content length restrictions: 0-1MB
    ["starts-with", "$Content-Type", "image/"], // content type restriction
    ["eq", "$x-amz-meta-userid", userid], // tag with userid <= the user can see this!
  ]
});

This allows significant more control over what kind of content that clients can upload by enforcing it from your server. For example restricting the file size (as mentioned on #64, #230).

* Extends existing functionality by type checking signResult
* Forks path based on receiving a string or an object with url / fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant