Skip to content

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