question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[🐛] Permission Denial: reading com.google.android.apps.photos.contentprovider.impl.MediaContentProvider uri

See original GitHub issue

Description

[ Android ] it failed to read content after fetching uri from google photo

Unhandled promise rejection [Error: Permission Denial: reading com.google.android.apps.photos.contentprovider.impl.MediaContentProvider uri content://com.google.android.apps.photos.contentprovider/0/1/content:/media/external/images/media/1259/ORIGINAL/NONE/image/jpeg/1615980699 from pid=20074, uid=10303 requires the provider be exported, or grantUriPermission()]

How to repeat issue and example

  • step to reproduce the issue
  • open google photo and choose file
  • and read file as base64 const base64Content = await RNFetchBlob.fs.readFile( decodeURIComponent(filePath), "base64" );

Solution

Need to inform how to handle ungranted permission

Additional Information

  • Image Picker version: [ “react-native-image-picker”: “3.0.0-vnext.4”.]
  • React Native version: [ “react-native”: “^0.63.2”.]
  • Platform: [Android] buildToolsVersion = “29.0.2” minSdkVersion = 24 compileSdkVersion = 29 targetSdkVersion = 29 supportLibVersion = “28.0.0”
  • Development Operating System: [MacOs]
  • Dev tools: [vscode]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ravirajn22commented, Mar 15, 2021

Latest version returns fileUri for images. I hope the issue is solved, if not reply here or create new issue with details I am happy to fix it.

1reaction
stefanoebcommented, Mar 13, 2021

It seems to be an issue when reading from photos saved in Google Photos. I’ve worked around this problem with a solution that looks like this:


import RNFetchBlob from 'rn-fetch-blob';
// ...
export async function getPathForFirebaseStorage(uri: string) {
  // The reason we have this function is that on android if the file comes from google photos we can't access it directly
  if (Platform.OS === 'ios') {
    return uri;
  }

  if (!uri.includes('content://com.google')) {
    return uri;
  }

  const stat = await RNFetchBlob.fs.stat(uri);
  return stat.path;
}

The function above will receive the path given by the picker and then return a proper path you can read from without any permission error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permission denied : opening provider com.google.android ...
I try to access a photo URI stored previously in SharedPreferences. . · You have a complicate pick intent. · The SharedPreference part...
Read more >
reading com.google.android.apps.photos.contentprovider.impl ...
Description. [ Android ] it failed to read content after fetching uri from google photo. Unhandled promise rejection [Error: Permission ...
Read more >
How to get read uri permission while retrying uri from shared ...
SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ...
Read more >
src/com/android/providers/media/MediaProvider.java
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and....
Read more >
Permission Denial: opening provider com.google.android ...
SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found