0

I have API server which is built on top of Node.js.

I've set response header for download data like below.

 res.setHeader('Content-Length', fileSize);
 res.setHeader('Content-Type', 'application/octet-stream');
 res.setHeader('Content-Disposition', 'attachment;filename="' + fileName + '"');

It works fine in any computer O/S and web browsers.

However, when I try to download data using android phone, any web browsers (eg., dolphine, chrome, FF) DOES NOT recognize response header (ie., filename, content-length)

Any one can help me to solve this problem?

Thanks in advance.

Hosang Jeon
  • 1,373
  • 1
  • 17
  • 37
  • try `res.writeHead` http://nodejs.org/api/http.html#http_response_writehead_statuscode_reasonphrase_headers – vinayr Dec 17 '13 at 06:46
  • Maybe Android browsers are creating an VIEW intent and there is no app installed listening on "application/octet-stream" mime-type? What kind of files are you sending? Try the same with "application/pdf". – hgoebl Dec 17 '13 at 08:40
  • @hgoebi I'm sorry but I have to send customer's data and I cannot determine what kind of data it would be.... – Hosang Jeon Dec 17 '13 at 11:51
  • @vinayr I'm sorry but it does not have any effect. – Hosang Jeon Dec 17 '13 at 12:03

1 Answers1

0

Finally, I found the reason why the http header does NOT work on android.

It's very sorry that I did not mention critical stuff.

Actually, I tried to download using https not http and since I'm using test server which has no valid SSL certification.

I could ignore SSL certification in web browsers in PC but Android.

It was the reason why Android web browser cannot read header.

I've changed the way to download from https to http, it works perfectly.

Thanks for all concerns and responses.

Thank you.

Hosang Jeon
  • 1,373
  • 1
  • 17
  • 37
  • its not working for me,any suggestion http://stackoverflow.com/questions/27579260/set-header-not-working-for-filename-in-nodejs – pitu Dec 20 '14 at 10:38