fix: rename cached media files to include extension when missing#22753
Merged
fix: rename cached media files to include extension when missing#22753
Conversation
Path resolution can drop the file extension when the source filename contains spaces (e.g. a Samsung screenshot named "screenshot_one ui home123.jpg" resolves to a cached path ending in "screenshot_one ui home123."). The existing code already derives the extension from the MIME type and appends it to the filename, but the on-disk file path was left unchanged. This caused downstream upload logic (wordpress-rs / reqwest) to fail MIME type detection from the path, resulting in "not allowed to upload this file type" errors. Rename the cached file on disk to include the correct extension so that the file path stored in the MediaModel is consistent with the filename. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bd628de to
23a08d6
Compare
|
Contributor
|
|
Contributor
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #22753 +/- ##
==========================================
- Coverage 37.43% 37.42% -0.01%
==========================================
Files 2320 2320
Lines 123589 123598 +9
Branches 16757 16760 +3
==========================================
Hits 46262 46262
- Misses 73608 73617 +9
Partials 3719 3719 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.





Description
Fix CMM-2003.
When a media file's source filename contains spaces (e.g. Samsung screenshots named
screenshot_20260327_072755_one ui home5107006954197938205.jpg), Android's path resolution can produce a cached file path that ends with a trailing dot — dropping the file extension entirely.The existing code in
FluxCUtils.mediaModelFromLocalUri()already derives the correct extension from the MIME type and appends it tofilename, but the on-disk file path (mFilePath) was left unchanged. SinceMediaRSApiRestClientpassesmFilePathto wordpress-rs, and reqwest infers the MIME type from the file extension in the path, the upload request was sent withContent-Type: application/octet-streamand a filename without an extension — causing WordPress to reject it with "Sorry, you are not allowed to upload this file type."This PR adds a step that renames the cached file on disk to include the correct extension when the path doesn't match, keeping
mFilePathconsistent withmFileName.Testing instructions
Upload a file with spaces in the filename:
Alternatively, create a test file manually:
test file upload.jpg)Regression — files without spaces: