简体   繁体   中英

express fileupload fails on large file size

Please bear with me I'm new to fileUpload express. I have simple form to upload file. It works for file size of around 50MB but it fails for file sizes more than 100MB.

Here is the HTML file:

<form action="/parse"
      method="post"
      ref="parse"
      encType="multipart/form-data">

<input type="file" class="btn btn-secondary input-file" name="inputFile" id="inputFile"/>
<input type="submit" class="btn btn-primary submit-btn" value="Upload"/>
</form>

And here is my initialization:

const fileUpload = require('express-fileupload');
var app = express();

app.use(fileUpload({
    limits: {
        fileSize: 1024 * 1024 * 1024 * 1024,
        abortOnLimit: false
    }
}));

It won't even hit my /parse url, it gives the following error on express app console:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   '~\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@5.6.0
3 info using node@v8.6.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle flow-trace-analizer@1.2.2~prestart: flow-trace-analizer@1.2.2
6 info lifecycle flow-trace-analizer@1.2.2~start: flow-trace-analizer@1.2.2
7 verbose lifecycle flow-trace-analizer@1.2.2~start: unsafe-perm in lifecycle true
8 verbose lifecycle flow-trace-analizer@1.2.2~start: PATH: ~\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;~\flow-trace-analizer\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Sennheiser\SoftphoneSDK\;~\apache-maven-3.3.9\bin;C:\Program Files\nodejs\;C:\Program Files\Git\bin;~\AppData\Roaming\npm;C:\Program Files (x86)\WebEx\PTools020000000;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\R\R-3.5.0\bin\R.exe;~\Gradle\gradle-4.7\bin;~\Groovy\groovy-2.4.12\bin;C:\Program Files\Heroku\bin;~\AppData\Roaming\npm
9 verbose lifecycle flow-trace-analizer@1.2.2~start: CWD: ~\flow-trace-analizer
10 silly lifecycle flow-trace-analizer@1.2.2~start: Args: [ '/d /s /c', 'node ./bin/www' ]
11 silly lifecycle flow-trace-analizer@1.2.2~start: Returned: code: 3  signal: null
12 info lifecycle flow-trace-analizer@1.2.2~start: Failed to exec start script
13 verbose stack Error: flow-trace-analizer@1.2.2 start: `node ./bin/www`
13 verbose stack Exit status 3
13 verbose stack     at EventEmitter.<anonymous> (
~\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.<anonymous> (
~\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid flow-trace-analizer@1.2.2
15 verbose cwd ~\flow-trace-analizer
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "~\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v8.6.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 3
22 error flow-trace-analizer@1.2.2 start: `node ./bin/www`
22 error Exit status 3
23 error Failed at the flow-trace-analizer@1.2.2 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3, true ]

No code change is needed. In your package json for start script, have this command:

"start": "node --max-old-space-size=4096 ./bin/www"

Or if you run your node file from command line, run it like:

node --max-old-space-size=4096 PATH/TO/YOUR/EXECUTABLE/NODE/FILE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM