Sunday, 4 June 2017

Node.js not available to download content from server

When anyone makes request from client to server on specified url, it needs to start downloading file for client. I have url like "site.com/some" so then request received on server for this url I want to send headers with filename and custom content (not from this file exactly), ex:

response.writeHead(200, {
'Content-Type': 'text/plain; charset=utf-8',
'Content-Disposition': 'attachment; filename="bla.txt"',
'Content-Length': 9
}
response.write('blablabla');
response.end();

I want next logic: after client gets back with response it starts downloading file "bla.txt" with content "blablabla". It doesn't work now, I haven't ideas why. Thanks anyone for help



via Vyacheslav

No comments:

Post a Comment