Reputation: 25
I need to handle a multiple file upload with ExpressJS where I dont't know the number of files uploaded by the client.
When I try to upload more than 244 files the server crash. The error is thrown during the upload between the upload form and the uploadHandle action. (the files are not all copied to my /public/upload folder, only the 244 first)
Increase the ulimit limitation seems to be a bit dirty because even if I set it to 10000, my server will crash if someone try to upload more files.
Is there a clean way to handle that ?
Thank you.
Upvotes: 0
Views: 282
Reputation: 1520
Not creating that many files at once feels like the correct approach. You could handle this several ways, such as queueing them in the browser using the HTML5 File Api if you don't have to support legacy browsers.
You could also stream the files on the server side as they are received so that you aren't creating open file pointers, and buffering them to memory. If you need to open all of those files and process them somehow, then as suggested, node-graceful-fs could help in that area.
Upvotes: 1