socketio-file-upload icon indicating copy to clipboard operation
socketio-file-upload copied to clipboard

Specify a custom directory for each upload

Open vote539 opened this issue 8 years ago • 3 comments

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

vote539 avatar Dec 30 '16 10:12 vote539

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.

TroyWolf avatar Aug 07 '18 20:08 TroyWolf

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.

sffc avatar Aug 07 '18 23:08 sffc

I published v0.6.2 which allows you to use the "saved" event on the server to move the file.

sffc avatar Aug 08 '18 19:08 sffc