Created
August 23, 2018 12:57
-
-
Save sanath-kumar/4b9967b4e2898daecc5bb23b896daabb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var AWS = require('aws-sdk') | |
var multer = require('multer') | |
var multerS3 = require('multer-s3') | |
AWS.config.loadFromPath('./s3_config.json') | |
var s3 = new AWS.S3() | |
var upload = multer({ | |
storage: multerS3({ | |
s3: s3, | |
bucket: 'YOUR-BUCKET-NAME', | |
acl: 'public-read', | |
metadata: function (req, file, cb) { | |
cb(null, {fieldName: file.fieldname}); | |
}, | |
key: function (req, file, cb) { | |
cb(null, Date.now().toString()+"-"+file.originalname) | |
} | |
}) | |
}); | |
module.exports = upload; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment