-
-
Save DanyF-github/31a3c7fa2aaaf5a8fde61416866b56a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// server/src/services/aws/s3.js | |
... | |
const presignedPostDocument = (keyName, isPublic = false) => { | |
const acl = isPublic ? 'public-read' : 'private'; | |
return new Promise((resolve, reject) => { | |
const params = { | |
Bucket: s3Bucket, | |
Fields: { | |
Key: keyName, | |
}, | |
Expires: 300, | |
Conditions: [ | |
['content-length-range', 0, 5242880], | |
['eq', '$Content-Type', 'application/pdf'], | |
{ acl }, | |
], | |
}; | |
s3.createPresignedPost(params, (err, data) => { | |
if (err) { | |
reject('Error while creating presigned post', err); | |
} else { | |
resolve(data); | |
} | |
}); | |
}); | |
}; | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment