Saturday, 29 April 2017

How to use aws s3 image url in node js lambda?

I am trying to use aws s3 image in lambda node js but it throws an error 'no such file or directory'. But I have made that image as public and all permissions are granted.

fs = require('fs');
exports.handler = function( event, context ) {

         var img = fs.readFileSync('https://s3-us-west-2.amazonaws.com/php-7/pic_6.png');
         res.writeHead(200, {'Content-Type': 'image/png' });
         res.end(img, 'binary');
};



via phpnerd

No comments:

Post a Comment