pastebin-worker icon indicating copy to clipboard operation
pastebin-worker copied to clipboard

Suggestion: Show file extension on upload result

Open Erisa opened this issue 3 years ago • 3 comments

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!

Erisa avatar Dec 09 '21 16:12 Erisa

It would be nice if the API/frontend could detect if the pasted content was a URL as well.

Misaka13514 avatar Feb 13 '22 10:02 Misaka13514

I am considering the following implementation:

When a paste is POST or PUT, the server checks if

  1. the filename stored in multipart/formdata contains a file extension that corresponds to a mimetype in mime-db.
  2. 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:

  1. Should deducedUrl be separated into mimeUrl and redirectUrl for better machine interoperability.
  2. When both condition is satisfied, which url should take priority.
  3. Is there a frontend design other than add one more field deducedUrl in the bottom table, since listing three similar URLs is a little bit stupid.

Or any better idea?

SharzyL avatar Feb 13 '22 11:02 SharzyL

TODO:

  • [ ] Documentation
  • [ ] Frontend display

SharzyL avatar Feb 14 '22 04:02 SharzyL