I am implementing some downloader application. Web client will send some data in web server. It will process the data and will create a file in some specific format and will push that file to client. I have done the part till creating the file using nodeJS. Now can someone suggest me how I can push the file to the client. It is like a downloader application, whenever web client sends the data, using some upload button, it will open a Save As window to save the file in client machine.
So can someone throw some light or pointer on some existing code stuff such that I can have a look?
Thanks in advance.
Regards,
-M-
You can see how do the Express Framework implement that: https://github.com/visionmedia/express/blob/master/lib/response.js#L356
Line 364: Set the Content-Disposition
header to tell the client this response is a attachment that can be downloaded.
this.set('Content-Disposition', 'attachment; filename="' + basename(filename) + '"');
Line 365: Send the file as the body of the response:
return this.sendfile(path, fn);
The send
module is used in the above function:
https://github.com/visionmedia/send