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

Option to add extension based on MIME type to URL from upload #7

Closed
laanwj opened this issue Sep 7, 2024 · 3 comments · Fixed by #32
Closed

Option to add extension based on MIME type to URL from upload #7

laanwj opened this issue Sep 7, 2024 · 3 comments · Fixed by #32

Comments

@laanwj
Copy link
Contributor

laanwj commented Sep 7, 2024

Currently at least nostrudel pastes the url field from the blob descriptor from an uploaded image directly into a nostr post. But nostr clients won't show an image when the URL doesn't end with an image extension such as jpeg, png, webp.

So from a usability point of view it would be useful if the blossom server added the extension. But this means that the server needs a map from upload MIME types to extensions, this isn't always straighforward.

Ostensibly, clients could also do this client-side (adding an extension is always allowed by the blossom protocol). And i imagine there are also non-nostr uses for blossom. So i'm not 100% sure this is a good thing to do server-side.

BUD 2 doesn't specify this, currently. See also discussion in hzrd149/blossom#25 and hzrd149/blossom#26 .

@0xtrr
Copy link
Owner

0xtrr commented Sep 7, 2024

I think that makes perfectly sense, the server always has the context of the file so we could easily always serve with the filetype at the end. I don't think this breaks anything with the protocol so if you have any code for this, I'll happily review it. I can also try to add it after I get tests added (probably not this weekend).

@laanwj
Copy link
Contributor Author

laanwj commented Nov 30, 2024

i've done some research here.

Easiest would be to use the mime2ext crate. This is compiled from a static version of mime-db, so will include pretty much every possible file type. Alternatively, if you prefer not to add a dependency, we could use an hardcoded list of media mime types that people are likely to upload.

@0xtrr
Copy link
Owner

0xtrr commented Dec 1, 2024

I don't mind adding the mime2ext crate, less code for us to maintain.

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

Successfully merging a pull request may close this issue.

2 participants