Skip to content

Copy the exported file to a temporary dir instead of the local Media dir #24595

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

crazytonyli
Copy link
Contributor

@crazytonyli crazytonyli commented Jun 18, 2025

Description

Fix #23025. This PR supersedes #24570, to address the issue raised in #24570 (comment).

Testing instructions

Verify that issue #23025 is fixed on WP.com sites and self-hosted sites.

Verify that photos, GIFs, and videos can be uploaded.

@crazytonyli crazytonyli added this to the 26.0 milestone Jun 18, 2025
@crazytonyli crazytonyli requested a review from kean June 18, 2025 03:59
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 26.0. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

Copy link

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number27873
VersionPR #24595
Bundle IDorg.wordpress.alpha
Commitc52ee05
Installation URL4r35f5oaa730g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number27873
VersionPR #24595
Bundle IDcom.jetpack.alpha
Commitc52ee05
Installation URL2jghek33a4ja0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Copy link
Contributor

@kean kean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks OK, but I think we might be over-complicating this a bit. I suggest capturing the name of the file immediate after it's loaded from the item provider and passing it here:

  private func configureMedia(_ media: Media, withExport export: MediaExport) {
        media.absoluteLocalURL = export.url
        media.filename = export.url.lastPathComponent

This way the URL of the exported/processed file becomes irrelevant.

wdyt?

@crazytonyli
Copy link
Contributor Author

I suggest capturing the name of the file immediate after it's loaded from the item provider and passing it here:

@kean Do you mean adding this change on top of of this PR, or using your suggested change without this PR?

There is another non-user-facing issue, along with the issue of "-1" in the uploaded image. When uploading an image, two image files are copied to the "local media directory": "foo.png" and "foo-1.png", which I'd like to fix too. There is no reason to store unused large files in the app's sandbox.

@kean
Copy link
Contributor

kean commented Jun 23, 2025

I'd probably suggest implementing it as a new/alternative fix, if you agree, of course.

When uploading an image, two image files are copied to the "local media directory": "foo.png" and "foo-1.png", which I'd like to fix too.

That's a good idea as these could really add up. It needs to remove temporary files after processing and remove everything after upload. There may be some code already doing it.

@crazytonyli
Copy link
Contributor Author

When uploading an image, two image files are copied to the "local media directory": "foo.png" and "foo-1.png", which I'd like to fix too.

That's a good idea as these could really add up.

Sorry, I was not clear at all in my previous comment. The issue of duplicated image files in the "local media directory" is also fixed in this PR.

Considering this PR fixes the issue with the uploaded media file name, and the issue I mentioned above regarding having duplicated image files in the "local media directory", I think we can take this PR's changes for now?

@crazytonyli crazytonyli requested a review from kean June 30, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS App Appends “-1” to Image Titles on Upload
4 participants