Skip to content
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

[android][image-picker] fix getting filename and filesize from cropped images #28352

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

fobos531
Copy link
Contributor

Why

Fixes #27554

How

It seems like the current method for fetching filename and file size via contentResolver method results in null values. However, it seems like accessing the File object directly that is acquired via outputFile produces the desired result both with cropped images and original images.

Test Plan

Tested on Pixel 8 Pro simulator with API 33. Untested on other API levels, but I believe this method should work on other API levels as well. Please let me know if that is not the case.

Note the filename and filesize values for both images with allowsEditing: false and allowsEditing: true

Before

CleanShot.2024-04-21.at.18.32.53.mp4

After

CleanShot.2024-04-21.at.18.34.26.mp4

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Apr 21, 2024
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Apr 21, 2024
Copy link
Collaborator

@alanjhughes alanjhughes left a comment

Choose a reason for hiding this comment

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

Hi @fobos531 - This solution is not correct. What you are returning for the filename is actually just a UUID appended to the file extension that we create when we create the output file, not the actual name of the file.

The cause of the problem is the cropped image does not exist in the content resolver so the solution is to fallback to using the file as you have as this cropped image will only exist where we wrote it too.

@fobos531
Copy link
Contributor Author

Hello @alanjhughes

That makes sense! Feedback applied.

@fobos531 fobos531 requested a review from alanjhughes April 22, 2024 06:59
Copy link
Collaborator

@alanjhughes alanjhughes left a comment

Choose a reason for hiding this comment

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

Great! Thanks for the fix @fobos531

Copy link
Contributor

@lukmccall lukmccall left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for your contribution🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[expo-image-picker] Cropped image returns null for fileName and filesize
4 participants