socketio-file-upload
socketio-file-upload copied to clipboard
Specify a custom directory for each upload
The example for uploadValidator
sets the global uploader.dir
property on the fly, which can have a race condition for two simultaneous uploads. A better approach would be to allow every file to have its own custom directory to override the global setting.
See #58 and #60
Related. I'm trying to set the uploader.dir in the uploadValidator similar to the documentation example: https://www.npmjs.com/package/socketio-file-upload#instanceuploadvalidatorevent-callback
I can debug output the value of uploader.dir and it is what I want, but the files are not uploaded into that directory. In fact, they go nowhere (apparently) unless I set uploader.dir "globally". (Just after instantiation to apply to all files.)
So I'd like to see setting upload.dir in uploadValidator work.
Perhaps I misunderstand @vote539 , but allowing the upload dir to be specified per file suggests the client sends this value. That seems like a not-so-secure thing to do.
For now, I recommend uploading all files to a default central location and then moving them to where you actually want them when done.
The example in the docs is not safe and should be removed. I'll do that soon.
I published v0.6.2 which allows you to use the "saved" event on the server to move the file.