Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
The problem seems to be the encoded URI. The aforementioned line `String filename = contentUri.getLastPathSegment()` is really the real point of failure.

On a redmi phone (maybe some others too?), the `contentUri` points to something like `content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20210301_082750.jpg`. So you see the encoded part. `getLastPathSegment()` extract the whole `%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20210301_082750.jpg` part, then decodes and returns it. Eventually, the follow outFile got a path like `...package..name.../cache/storage/emulated/0/DCIM/Camera/IMG_20210301_082750.jpg`, and you see where it crashes.

I'm not sure if I'm doing it the tidy way, it's the most straightforward way I can think of.
  • Loading branch information
eidng8 authored Mar 1, 2021
1 parent 1a831ab commit 1fe47b1
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private void processEditedImage(PluginCall call, ActivityResult result) {
* @throws IOException
*/
private Uri saveTemporaryImage(Bitmap bitmap, Uri contentUri, InputStream is) throws IOException {
String filename = contentUri.getLastPathSegment();
String filename = Uri.parse(Uri.decode(contentUri.toString())).getLastPathSegment();
if (!filename.contains(".jpg") && !filename.contains(".jpeg")) {
filename += "." + (new java.util.Date()).getTime() + ".jpeg";
}
Expand Down

0 comments on commit 1fe47b1

Please sign in to comment.