pastebin-worker
pastebin-worker copied to clipboard
Suggestion: Show file extension on upload result
Hello!
I noticed when you upload a file, you are able to upload formats other than plain text, for example an image, and view them back. I also noticed that the correct content-type can be returned by adding an extension to the URL. For example https://shz.al/Si3d.jpg
It would be nice (If possible) if the API/frontend would detect the file extension of the file I'm uploading, and suggest that file extension for the resulting URL, to increase discoverability of this functionality and make the service function for uploading and sharing files as well (Is that out of scope? I assumed not considering the rest of the stuff for it is here)
I do have my own instance that I would be using, just used yours for the example URL for simplicity!
It would be nice if the API/frontend could detect if the pasted content was a URL as well.
I am considering the following implementation:
When a paste is POST or PUT, the server checks if
- the filename stored in multipart/formdata contains a file extension that corresponds to a mimetype in mime-db.
- the content is a valid URL
If either of the above conditions is satisfied, a field deducedUrl (or some other name) is added in the return JSON. The field should be like shz.al/abcd.jpg or shz.al/u/abcd.
Issues to be considered:
- Should
deducedUrlbe separated intomimeUrlandredirectUrlfor better machine interoperability. - When both condition is satisfied, which url should take priority.
- Is there a frontend design other than add one more field
deducedUrlin the bottom table, since listing three similar URLs is a little bit stupid.
Or any better idea?
TODO:
- [ ] Documentation
- [ ] Frontend display