I am trying to send a multipart/form-data form to an AWS-Lambda method. I need to be able to send files to S3, and using incoming string parameters, I need to record metadata to RDS.
Now, I can do that using express and multer-s3 as follows;
var express = require('express');
var AWS = require('aws-sdk');
var multer = require('multer')
var multerS3 = require('multer-s3')
var s3 = new AWS.S3();
const app = express();
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'my-bucket-name',
metadata: function (req, file, cb) {
cb(null, Object.assign({}, req.body));
},
key: function (req, file, cb) {
cb(null, Date.now().toString() + '.fileExtension')
}
})
})
app.post('/data', upload.array('file'), function(req, res, next) {
// here using req.files, i can save metadata to RDS
})
My question is, is it possible to use multer-s3 in an AWS Lambda method? If the answer is no, or it's not recommended, could you please point me in the right direction?
Thanks..