Created
December 26, 2018 04:10
-
-
Save dmurawsky/09c5cba785a1734bbc80b022053933f3 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
const express = require('express') | |
const app = express() | |
const AWS = require('aws-sdk') | |
const s3 = new AWS.S3() | |
const signedUrlExpireSeconds = 60 * 5 | |
const bucket = 'mf-uploads' | |
app.post('/signed-url', (req, res) => { | |
// req.body.method = 'getObject' for download url or 'putObject' for upload url | |
const url = s3.getSignedUrl(req.body.method, { | |
Bucket: bucket, | |
Key: req.body.filename, | |
Expires: signedUrlExpireSeconds | |
}) | |
res.json({ url }) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment