-
Notifications
You must be signed in to change notification settings - Fork 269
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
fix(ffi): Generate correct temporary file names for media attachments #1851
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #1851 +/- ##
==========================================
- Coverage 76.44% 76.42% -0.02%
==========================================
Files 140 140
Lines 15977 15977
==========================================
- Hits 12214 12211 -3
- Misses 3763 3766 +3
☔ View full report in Codecov by Sentry. |
d4f2149
to
906a573
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok seems reasonable to me. Having thought about it, given the spec says the body should be the filename, it does seems reasonable to take that first and if it fails use the mimetype as a fallback. Let's see how it works in the real world 🤞
d0863c8
to
25a07f0
Compare
25a07f0
to
dfc20ed
Compare
Fixes element-hq/element-x-ios#843
As the issue above describes, simple text files (and surely others) aren't currently renderable iOS side. This happens because we use
mime_guess
to infer an extension from the content type and that results in a list of extensions sorted in no particular order. In this casetext/plain
results inasm
because it just happens to be the first match from this list which iOS doesn't know what to do with.To fix that this PR switches over to mime2ext (like this comment from
mime_guess
suggests) which does return more commonly used extensions.Separately, the
body
of an attachment is usually its original filename which we are currently not using. This PR also addresses that by adding an optionalbody
property and trying to use it as much as possible when generating the temporary file name. This will in turn show up in the iOS system dialogs when trying to save said file.