I am using webshot on my node(sails js) project to convert an html string to an image and then upload that image to a s3 bucket. When I run it on my local machine, it works fine i.e it generates an image and I am able to upload that image to s3 bucket. But when I run the same code on a EC2 instance(ubuntu v16), it just doesnt work. It just doesnt create any image and hence nothing gets uploaded.
Here is my code -
var htmlString = '<div>a long html string</div>';
webshot(htmlString,'img.png', options, function(err) {
fs.readFile('img.png', function (err, data){
if(err){
console.log('error reading file');
}else{
var params = {
Bucket: bucket,
Key: 'customPNGs/'+'img.png',
Body: data,
ACL: 'public-read',
ContentType: 'image/png'
};
s3.putObject(params, function (err, res) {
if (err) {
sails.log.error("Error uploading data: ", err);
} else {
console.log('uploaded')
}
});
}
});
I tried doing the uploading directly to s3 using streams but it uploads a 0kb file.
Here is my code using the stream
var renderStream = webshot(quitImageHTML, null, options);
var ss = '';
renderStream.on('data', function(data) {
ss+=data.toString('binary');
});
renderStream.on('end', function() {
//upload using the above code
});
Please help. Its urgent for me to get it working for my project asap. Thankz in advance.
Hi there.
I am using webshot on my node(sails js) project to convert an html string to an image and then upload that image to a s3 bucket. When I run it on my local machine, it works fine i.e it generates an image and I am able to upload that image to s3 bucket. But when I run the same code on a EC2 instance(ubuntu v16), it just doesnt work. It just doesnt create any image and hence nothing gets uploaded.
Here is my code -
I tried doing the uploading directly to s3 using streams but it uploads a 0kb file. Here is my code using the stream
Please help. Its urgent for me to get it working for my project asap. Thankz in advance.