Skip to content

fix(blossom): send the real content type on upload - #85

Merged
TheCryptoDonkey merged 1 commit into
mainfrom
fix/blossom-content-type
Aug 6, 2026
Merged

fix(blossom): send the real content type on upload#85
TheCryptoDonkey merged 1 commit into
mainfrom
fix/blossom-content-type

Conversation

@TheCryptoDonkey

Copy link
Copy Markdown
Member

What this changes

blossom-upload now sends the actual media type instead of application/octet-stream.

Why

No caller passes contentType, so every upload fell back to the default. A Blossom server that sniffs the body rejects the mismatch:

$ nostr-bray blossom-upload https://blossom.band ./logo.png
Blossom upload failed: 400 Content-Type header does not match the file content, expected image/png

The file was a valid PNG. This makes blossom-upload fail against any spec-compliant server for every format it recognises.

How

Detect from the leading bytes rather than the file name. The bytes are what the server checks, and an uploader should not be able to mislabel a blob by renaming it. PNG, JPEG, GIF, WebP, PDF and SVG, falling back to application/octet-stream when nothing matches, so unknown formats behave exactly as before.

An explicit args.contentType still wins, so existing callers are unaffected.

Verification

Same upload after the fix returns 200 with "type": "image/png", and the blob serves as image/png. Unit tests cover each signature and the short-buffer and unknown-format fallbacks. npm run lint and the blossom suite (47 tests) pass.

every upload went out as application/octet-stream because no caller passes
contentType, and a blossom server that sniffs the body rejects the
mismatch: uploading a valid png returned 400 'Content-Type header does not
match the file content, expected image/png'.

detect from the leading bytes rather than the file name. the bytes are
what the server checks, and an uploader should not be able to mislabel a
blob by renaming it. png, jpeg, gif, webp, pdf and svg, falling back to
octet-stream when nothing matches.
@TheCryptoDonkey
TheCryptoDonkey merged commit c30fc23 into main Aug 6, 2026
5 checks passed
@TheCryptoDonkey
TheCryptoDonkey deleted the fix/blossom-content-type branch August 6, 2026 14:42
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 this pull request may close these issues.

1 participant