有誰知道如何讀取或訪問HTTP響應的附件?NodeJS從HTTP響應中讀取文件附件
我的意思是,服務器的響應是:
HTTP/1.1 200 OK
Server: something
Date: Fri, 01 May 2015 10:22:29 GMT
Content-Type: application/pdf
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Language: en
Content-Disposition: attachment; filename=mybill-234324.pdf
Set-Cookie: s=xxxxx; expires=Fri, 15-May-2015 10:22:29 GMT; httponly; Max-Age=1209600; Path=/; secure
Strict-Transport-Security: max-age=15552000
但是這是哪裏mybill-234324.pdf文件內容???
我的代碼:
var req = https.request({
method: 'GET',
host: 'thehost.ext',
path: '/account/bills/' + number + '/',
headers: {
'Cookie': 's=supercryptedhash;',
'Accept-Language': 'en-US,en'
}
}, function(res) {
// ????
});
req.on('error', function(err) {
console.error('Request Error', err);
});
req.end();
提供的代碼示例,請在問題編輯提供 – vanadium23
。 –
嘗試看到答案:http://stackoverflow.com/questions/20132064/node-js-download-file-using-content-disposition-as-filename – vanadium23