-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
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.
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.
packages/expo-image-picker/android/src/main/java/expo/modules/imagepicker/MediaHandler.kt
Outdated
Show resolved
Hide resolved
packages/expo-image-picker/android/src/main/java/expo/modules/imagepicker/MediaHandler.kt
Outdated
Show resolved
Hide resolved
Hello @alanjhughes That makes sense! Feedback applied. |
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.
Great! Thanks for the fix @fobos531
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.
Looks good! Thanks for your contribution🥇
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
npx expo prebuild
& EAS Build (eg: updated a module plugin).