问题
Using Sails.js to upload images to Azure with this code:
req.file('picture').upload({
adapter: require('skipper-azure'),
key: storageAccount,
secret: accessKey,
container: 'default'
}, function(err, files) {
if(!err) {
return res.json(cdn + files[0].fd);
} else {
return res.send(err);
}
});
I have 2 problems:
- Files are buffered to memory instead of being streamed
- The memory is not freed-up when file upload is done, is it a Node.js problem, Sails.js', or my problem?
UPDATE
When I upload a 512MB file, I receive the following error on Heroku:
2016-01-05T17:17:18.083883+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/uploader/upload" host=abc.herokuapp.com request_id=fc2c32ed-35da-48de-8949-20f2a505d8eb fwd="41.35.30.180"
dyno=web.1 connect=0ms service=120024ms status=503 bytes=0
2016-01-05T17:17:18.081447+00:00 app[web.1]: undefined
2016-01-05T17:17:18.089304+00:00 app[web.1]: Sending 500 ("Server Error") response: 2016-01-05T17:17:18.089309+00:00 app[web.1]: Error: Request aborted 2016-01-05T17:17:18.089311+00:00 app[web.1]: at IncomingMessage.onReqAborted (/app/node_modules/skipper/node_modules/multiparty/index.js:175:17)
2016-01-05T17:17:18.089311+00:00 app[web.1]: at emitNone (events.js:67:13) 2016-01-05T17:17:18.089312+00:00 app[web.1]: at IncomingMessage.emit (events.js:166:7)
2016-01-05T17:17:18.089313+00:00 app[web.1]: at abortIncoming (_http_server.js:280:11) 2016-01-05T17:17:18.089314+00:00 app[web.1]: at Socket.serverSocketCloseListener (_http_server.js:293:5)
2016-01-05T17:17:18.089314+00:00 app[web.1]: at emitOne (events.js:82:20)
2016-01-05T17:17:18.089315+00:00 app[web.1]: at Socket.emit (events.js:169:7) 2016-01-05T17:17:18.089316+00:00 app[web.1]: at TCP._onclose (net.js:469:12) [Error: Request aborted]
来源:https://stackoverflow.com/questions/34609254/node-js-file-upload-buffers-in-memory-and-memory-not-freed-up-after-upload-is-d