I'm trying to upload to S3 using aws-sdk and Node/Express. When I go through this process I get no errors and land on the "successfully uploaded" page. However the new file does not show up in my amazon bucket. Where am I going wrong?
Thank you for any help!
var aws = require('aws-sdk');
var multerS3 = require('multer-s3');
var multer = require("multer");
aws.config.update({
secretAccessKey: 'MYKEY',
accessKeyId: 'MYKEY',
region: 'us-east-2'
});
var s3 = new aws.S3();
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'medstayfiles',
metadata: function (req, file, cb) {
cb(null, {image: file.fieldname});
},
key: function (req, file, cb) {
cb(null, Date.now().toString())
}
})
})
Posting
router.post('/', upload.array('photos', 1), function(req, res, next) {
res.send('Successfully uploaded')
})
Form
<form action="/rentals" method ="POST">
<input type="file" name="image" id="image">
<div class="form-group"> <button>Submit!</button> </div>
</form>
via AndrewLeonardi
No comments:
Post a Comment