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

Save uploaded file atomically #1369

Open
ubruhin opened this issue Mar 21, 2024 · 2 comments
Open

Save uploaded file atomically #1369

ubruhin opened this issue Mar 21, 2024 · 2 comments

Comments

@ubruhin
Copy link

ubruhin commented Mar 21, 2024

It seems when uploading a file, the file is immediately created and any incoming data is written into it. However, this means the file is incomplete/invalid during the upload and there's no way to know as a user (or, in my case a tool processing the uploaded files) whether a file is complete or not. I didn't check what happens when an upload is aborted/fails, is the incomplete file then even left over?

Anyway, IMHO the upload would be much safer if the file is saved atomically. Just as a simple idea, the upload could be performed into a temporary file (e.g. ending with ~) and renamed when the upload succeeded. This way it is visible for humans and detectable by tools which files are incomplete.

@svenstaro
Copy link
Owner

I like this suggestion and agree with you reasoning. I won't have time to tend to this, though. I'd be very happy to review a pull request, though.

@chaibiq
Copy link
Contributor

chaibiq commented Mar 30, 2024

Hi, I have been trying add and to test upload files with progress bar. I use external vanilla JS and CSS file to use XHR to upload files. If it's complete, I will submit PR after merge to main code without external file.
Here is it look like now:
318087142-53a9410f-a05f-4b09-975b-7299db14575f

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