-1
所以我有一種奇怪的錯誤。如果我做以下操作:節點流添加標頭錯誤地發送文件
res.header('content-disposition', 'filename=' + mediaObject.file.originalname);
我可以下載該文件。
但是隻要我一個額外的行添加到標題中的文件下載錯誤,例如:
res.header('content-disposition', 'filename=' + mediaObject.file.originalname,"Content-Length: " + mediaObject.file.size);
的的mediaObject
值:
File:
buffer: null
encoding: 7bit
extension: mp4
fieldname: file
mimetype: video/mp4
name: test1434922812720.mp4
originalname: test.mp4
path: uploads/test1434922812720.mp4
size: 22179964
truncated: false
所以我的問題是我是什麼?做錯了?
如果即時通訊試圖流 –
這是沒有提到你的問題。爲了流式傳輸,我會在節點中創建一個讀取流(使用fs.createReadStream),並將流傳遞給響應。 –