jrvansuita / PickImage

📸 🖼️ Shows a DialogFragment with camera and gallery options. User can choose which provider wants to pick images from.
MIT License
469 stars 107 forks source link

Permission denied if opening image from gallery #37

Closed robnoflop closed 7 years ago

robnoflop commented 7 years ago

Hi,

when I'm open an Image from gallery im getting the error: java.io.FileNotFoundException: Permission denied

I'm using UCrop with the PickResult I got. The Problem is that I can not access the URI in the result.

UCrop.of(r.getUri(), Uri.fromFile(new File(getCacheDir(), destinationFileName))) .withAspectRatio(1, 1) .withMaxResultSize(1024, 1024) .withOptions(o) .start(context);

Can you implement the permission request for external files for the gallery?

lampione commented 7 years ago

Same happening for me, library ask permission when I choose camera option but not if I choose to pick an image from gallery. Currently easy to workaround but I think it would be "consistent" to add the permission request on both options.

jrvansuita commented 7 years ago

@lampione @robnoflop Are you experiencing any error or permission denied when select gallery for the first time? Because it's a normal behavior. Using my phone, I can pick any images from gallery without any permission.

lampione commented 7 years ago

@jrvansuita choosing gallery, no matter if first or second time, I can explore my gallery and pick any image but when I get back to my app, the .getError() method is not null, and it says that there's no such file. Manually giving archive permission to my app restore the default functionality.

lampione commented 7 years ago

The error generated is:

java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/IMG_20170815_194611.jpg: open failed: EACCES (Permission denied)

This only happens for API >= 23 of course

varunagp commented 7 years ago

i agree with @robnoflop as he says we get permission denied if we select gallery.

Steps to Reproduce - App is installed, if you select the camera option it will ask you for permissions of both Camera and Gallery, but instead if you select only Gallery for the very first time then if fails as permissions are not granted.

Can anyone please fix this.

jrvansuita commented 7 years ago

Fixed. Look onto next version.