- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
尝试使用 express 将大文件上传到 Node js 实例,但大文件会失败。出现以下错误消息:
Error: Request aborted
at IncomingMessage.<anonymous> (/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js:107:19)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at abortIncoming (http.js:1892:11)
at Socket.serverSocketCloseListener (http.js:1904:5)
at Socket.EventEmitter.emit (events.js:117:20)
at TCP.close (net.js:466:12)
/server/upload/
buffer.js:194
this.parent = new SlowBuffer(this.length);
^
RangeError: length > kMaxLength
at new Buffer (buffer.js:194:21)
at fs.js:220:16
at Object.oncomplete (fs.js:107:15)
31 Jul 14:01:04 - [nodemon] app crashed - waiting for file changes before starting...
当我不想分块数据时,我该怎么做才能避免这个错误?
希望有人能帮忙解决;-)
最佳答案
如果分析错误信息
buffer.js:194
this.parent = new SlowBuffer(this.length);
^
RangeError: length > kMaxLength
可以看到kMaxLength是一个常量,指定进程的内存限制。
来自 https://github.com/joyent/node/wiki/FAQ
Currently, by default v8 has a memory limit of 512mb on 32-bit systems, and 1gb on 64-bit systems. The limit can be raised by setting --max-old-space-size to a maximum of ~1gb (32-bit) and ~1.7gb (64-bit), but it is recommended that you split your single process into several workers if you are hitting memory limits.
所以你可以用标志执行 Node
node --max-old-space-size=2000 app.js
标志单位以 MB 为单位,请参阅 ( https://github.com/joyent/node/blob/master/deps/v8/ChangeLog)
关于javascript - 使用 node 和 express 上传一个大文件(1GB),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17969880/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!