【发布时间】:2016-08-08 23:13:11
【问题描述】:
我有一个在 nodejs 上运行的服务器,我有以下代码来管理发布请求 -
form.on('file', function (field, file) {
var RecordingInfo = JSON.parse(file.name);
...
当我尝试上传文件时,出现以下异常:
undefined:1
"}
SyntaxError: Unexpected end of input
at Object.parse (native)
at IncomingForm.<anonymous> (.../root.js:31:34)
...
searching around the web,我喜欢这个异常是因为数据是按位来的,并且在第一位到达后触发事件,而我没有所有的数据。好的。问题是,经过一些测试后,我喜欢从 chrome 上传大文件(尝试了 1.75gb 文件)而没有任何问题,而 firefox 使用 6kb 文件使服务器崩溃。
我的问题是 - 为什么它们不同?
可以从here 下载示例捕获。第一篇来自chrome,第二篇来自firefox。
上传前完整的file.name字符串为:
// chrome
"{"subject":"flksajfd","lecturer":"אבישי וינר","path":"/גמרא","fileType":".png"}"
// firefox
"{"subject":"fdsa","lecturer":"אלקס ציקין","path":"/גמרא","fileType":".jpg"}"
(提交的数据不一样,但我觉得没关系)
【问题讨论】:
-
FF 和 Chrome 的输入有什么区别?
-
@Oleander 我添加了来自 wireshark 的捕获。
标签: node.js firefox formidable