We are trying to build a large file (size>30MB) upload from Android and iOS phones, for that created an Express.js API for file upload.
Endpoint: user/upload
uploadFile:function(req,res){
//upload files to AWS s3 asychrnous
s3.upload(params,options,function(err, data) {
//when upload complete
//need a help on this part
if(data){
//Send a notification to client
}
});
res.json({
status:true,
'message':'Upload ongoing'
});
}
When user requests the API (user/upload) it immediately give this response:
{
status:true,
'message':'Upload ongoing'
}
Because the upload is asynchronous. So how can I notify the client when upload completes?
For the specific usecase, I would recommend the following flow
Above flow is completely asynchronous and highly scalable reducing the load for your express API.