-
Notifications
You must be signed in to change notification settings - Fork 84
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
Allow overwriting files #65
Comments
@DaneEveritt , a couple of directions to go here. Caveat that I'm looking at socketio-file-upload today, and it might have changed since you posted back on Jan 15, 2017. Note that siofu detects existing file and adds a numeric suffix to the filename to ensure a unique name. I understand your desire to overwrite the existing file rather than create a new filename. A common strategy (at least what I'm doing) is to upload to a temp dir. I listen for the "saved" event from siofu server-side. The object returned tells me the new filename--the full path. My "saved" event handler then moves the file into a permanent location. In that code, I have full control over naming, overwriting, etc. A 2nd strategy that I think would work from reading the docs...check out: In that callback, you get an object that tells you the filename being uploaded. In this handler, you could write code to see if the file already exists, and if so, delete it or rename it. This way, when siofu goes to save the file, it will not find an existing file. I have not tested this. I use uploadValidator() to specify an upload directory specific to each file uploaded. I rely on siofu's meta support to include a bit of data that I use inside that method. |
TroyWolf's post is correct. You can listen for the "saved" event and move the file if you like. Another option is to bypass all of siofu's file handling operations by setting |
Unless I'm not seeing the option, it seems there is no way to allow the uploader to overwrite a file if it already exists.
The text was updated successfully, but these errors were encountered: