Fix documents arriving as unnamed .bin files (mime type + FileName) - #328
Open
NahumLitvin wants to merge 1 commit into
Open
Fix documents arriving as unnamed .bin files (mime type + FileName)#328NahumLitvin wants to merge 1 commit into
NahumLitvin wants to merge 1 commit into
Conversation
Two gaps made every send_file document render as an unnamed .bin on recipients' phones: - unknown extensions fell through to application/octet-stream; now the mime type is resolved with the stdlib mime.TypeByExtension, keeping octet-stream only as the last-resort fallback - DocumentMessage carried Title but no FileName, and WhatsApp mobile clients use FileName for the displayed name and extension Fixes lharries#327
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #327.
I hit this sending a PDF to my wife: it arrived on her phone as an unnamed
.binwith no preview. Two things cause it: the extension switch falls through toapplication/octet-streamfor anything that isn't a known image/audio/video type, andDocumentMessageis built withoutFileName, which mobile clients use for the displayed name and extension.This is the minimal fix: resolve the mime type with the stdlib (
mime.TypeByExtension), keeping octet-stream only as the empty-lookup fallback, and setFileNamenext toTitle. 7 lines. Verified on my own bridge — the same PDF now arrives named, with the right icon and preview, on iOS and Android.I know #157, #199, #236, #243 and #316 touch the same area; this one is just the smallest diff that fixes the reported behaviour, in case that's easier to review. Happy to close it in favour of any of those.