Skip to content

Fix room and user avatar downloaded with a .bin extension. #4830

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

Merged
merged 1 commit into from
Jun 6, 2025

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Jun 5, 2025

Content

Let the SDK set a correct extension to downloaded file by providing a full mimetype when a base mimetype is available.

Motivation and context

Fixes #4803

Screenshots / GIFs

Tests

  • Open a room avatar and downloaded it to the system.
  • Observe that the extension of the downloaded file is no jpeg, it was bin previously.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

… full mimetype when a base mimetype is available.

Fixes #4803
@bmarty bmarty requested a review from a team as a code owner June 5, 2025 14:24
@bmarty bmarty requested review from ganfra and removed request for a team June 5, 2025 14:24
@bmarty bmarty added the PR-Bugfix For bug fix label Jun 5, 2025
Copy link
Contributor

github-actions bot commented Jun 5, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/XKYTwH

Copy link

sonarqubecloud bot commented Jun 5, 2025

@jmartinesp
Copy link
Member

jmartinesp commented Jun 5, 2025

I think this is doing what iOS does, assuming images are jpgs. At least, when I downloaded this image it appeared as .jpeg and when you open it with a hex editor you can see it's a PNG.

tmpe4nNwf

It's better than what we have, but I was thinking about something more like this option.

@bmarty
Copy link
Member Author

bmarty commented Jun 6, 2025

It's better than what we have, but I was thinking about something more like this option.

Yes, I was thinking about that too, but here, it appears that it's the Rust SDK which downloads the file and decides of its extension based on the provided mime type. So I'd argue that this problem could be fixed SDK side.

In the meantime I think that this fix is enough as a first step. Do you agree?

@jmartinesp
Copy link
Member

Yes, it's probably fine. Also, it seems like there are some very handy mime type libraries on Rust that could solve this problem instead of us re-implementing them ourselves. It's probably worth a shot doing it there.

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 80.46%. Comparing base (3ba11db) to head (c704a47).
Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
...oid/libraries/matrix/impl/media/RustMediaLoader.kt 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4830      +/-   ##
===========================================
- Coverage    80.47%   80.46%   -0.01%     
===========================================
  Files         2140     2140              
  Lines        56756    56762       +6     
  Branches      7110     7114       +4     
===========================================
  Hits         45672    45672              
- Misses        8649     8655       +6     
  Partials      2435     2435              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bmarty bmarty merged commit c3bbac1 into develop Jun 6, 2025
33 of 37 checks passed
@bmarty bmarty deleted the feature/bma/fixDownloadAvatar branch June 6, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Downloading pfp/room picture corrupts it
3 participants