Friday, 14 April 2017

My lambda function not working locally using node js

I have tried to upload file from Lambda Function using node js also I need to do add more logic inside my lambda functon.But my Lambda function is not calling.Am using express module,by default its calling app.get() method only.So how to call my Lambda function in express module.

var express = require('express');
var app = express();

app.set('port', process.env.PORT || 3000);

 app.get('/', function (req, res) {

});


var lambdaFunc = function (event, context) {

var body = fs.createReadStream('./tmp/student/saravt.txt');

var fileKey1 = "saravt.txt";

var s3obj = new AWS.S3({ params: { Bucket: bucketName, Key: fileKey1 } });
s3obj.upload({ Body: body }).
on('httpUploadProgress', function (evt) {
    console.log(evt);
})
.send(function (err, data) {
    console.log(err, data)
});
};

exports.handler = lambdaFunc;



http.createServer(app).listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});



via vishnu

No comments:

Post a Comment