I have a lambda function which pushes data to s3. This is the function :
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
exports.handler = function(event, context) {
var s3 = new AWS.S3();
var param = {Bucket: 'test', Key: 'testFile', Body: JSON.stringify(event)};
console.log("EVENT DATA :" + param.Body);
s3.upload(param, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
console.log('actually done!');
context.done();
});
console.log('done?');
};
I need two modifications :
1) each and every time this lambda function is invoked, i want it to create a different file to push the data to it.
2) there is a folder "test1" inside bucket "test", I want to push the data inside test1 folder if test1 folder is available or else create test1 folder inside test bucket and push the data inside it.
Can you help me with this?
Thanks.