Currently i am using putObject to upload the large file to AWS s3 with REST api call.
var params ={
Bucket:'lambdacushbu',
Key:req.files.image.name,
Body:req.files.image.data
}
s3.putObject(params,function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
console.timeEnd('Uploadtime');
console.log("uploaded",data);
res.json({
'status':'Uploaded',
'url':data.Location
});
} // successful response
});
But its looks like asynchronous i want the above in synchronous mode also a timeout is occurred but the file is being uploaded to the AWS s3.
So how can i increase the timeout value?? tried with connect-timeout package
app.use(timeout('600000'));
But it dosen't worked
Try using the upload function instead of putObject . That should solve your timeout issue.
Here is a documentation for that feature: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
Synchronous calling will definitely slow down the performance of your application. Can you provide me with more details about your problem so we can find an asynchronous solution?
EDIT: This is how you should return the response in your controller:
router.post('/your-route', //additional middlewares function(req, res, next) { var params = { Bucket:'lambdacushbu', Key:req.files.image.name, Body:req.files.image.data } s3.upload(params,function(err, data) { if (err) { res.json(err); } else { res.json({ 'status':'Uploaded', 'url':data.Location } }); } ); And make sure you don't call res.json() or res.send() anywhere else in this route