- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4
 
Preserve file extension for unique filenames #21
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
Conversation
| 
           Thanks @juntyr for catching this! It looks like the current implementation would then create a file named  Wondering if it should be named   | 
    
          
 The file will be renamed once the upload of that file is completed anyways, so it will get its original name in the unique upload folder back. But if the name during this upload period matters, then your solution would be nicer.  | 
    
| 
           I've been thinking a bit more about this. Extensions can meaningfully have one or multiple parts and I think it's really just easier to leave them be entirely, i.e. to not even try to determine where they start and end. Adding a prefix to the filename on upload may look weird for the split-second before the file is moved and renamed to the final location, but it works and fixes an existing bug. @jtpio Would you be willing to merge this PR and release a patch release for this bug fix?  | 
    
          
 Ah right, if it's just temporary then it's probably fine.  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
          
 Thank you so much <3  | 
    
When a file is uploaded and has a name clash, a unique filename must be chosen. The current method appends the increment after the pathname, which interferes with the file extension, e.g.
README.mdbecomesREADME.md_0. (Since the contents API uses the extension to determine how to interpret the file, this causes plain text files to be displayed as base64 encoded). The new variant puts the disambiguator in front to preserve the extension.