Search code examples
node.jsexpresshttp-range

express.js Check if partial range download finished


I am using res.download in express.js on my server to give a file for download. If I support partial range in my server callback function of res.download will be called several times. How can I know when download is completely finished?

res.download(filePath, fileName, function(){
// Error handling 
if(req.headers.range)
{
// downloading with range support 
// here will be called several times
}
}) 

Solution

  • I figured out there is no way to acknowledge that as every portion of file will be downloaded separately and raise its own finish method. So client would call another api to let the server know the download is completed.