Thursday 20 April 2017

File upload via api in express js :Notification after file upload

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 request 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.



via Jabaa

No comments:

Post a Comment