Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify a custom directory for each upload #62

Open
vote539 opened this issue Dec 30, 2016 · 3 comments
Open

Specify a custom directory for each upload #62

vote539 opened this issue Dec 30, 2016 · 3 comments

Comments

@vote539
Copy link
Collaborator

vote539 commented Dec 30, 2016

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

@TroyWolf
Copy link

TroyWolf commented Aug 7, 2018

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.

@sffc
Copy link
Owner

sffc commented Aug 7, 2018

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 added a commit that referenced this issue Aug 8, 2018
Previous code sample had race condition; see #62.

Added note that the "saved" event can be used to move the file.
sffc added a commit that referenced this issue Aug 8, 2018
This event should be able to be used to move the file. See #62
@sffc
Copy link
Owner

sffc commented Aug 8, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants