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

how do decode Android content:// uris? #183

Closed
raould opened this issue May 26, 2017 · 3 comments
Closed

how do decode Android content:// uris? #183

raould opened this issue May 26, 2017 · 3 comments

Comments

@raould
Copy link

raould commented May 26, 2017

Does react-native-contacts have a way to convert "content://com.android.contacts/display_photo/9" to a local file uri? Or should I be using something like https://stackoverflow.com/questions/36259339/convert-content-uri-to-actual-path-for-android-using-react-native? Thanks. :)

Currently I am using Image with { uri: item.thumbnailPath } but the image ends up blank. Trying to understand the way I should be doing it. The README says that's how I should be doing it I think.

Displaying Thumbnails

The thumbnailPath is the direct URI for the temp location of the contact's cropped thumbnail image.

<Image source={{uri: contact.thumbnailPath}} />

I also just tried getPhotoForId() with the "recordID" (e.g. '9') but the callback always gets null for the url.

(I am pretty sure there are images since I can see them in the Android OS's contacts app, and could see them via a Cordova contacts app.)

@raould
Copy link
Author

raould commented May 30, 2017

This does work, I found & fixed another issue in my layouts that was breaking the images. (If anybody else gets confused in the future: things like <Image source={uri:'content://com.android.contacts/display_photo/10'} /> does work, w/out needing more translation.)

@raould raould closed this as completed May 30, 2017
@EyalSi
Copy link

EyalSi commented Oct 3, 2017

Seems like presenting the image, as @raould wrote, is working, but copy the image with either react-native-fs or react-native-fetch-blob, fails. Seems like both of them do not support the content prefix.
Has anyone succeeded in copying those images on Android?

@EyalSi
Copy link

EyalSi commented Jan 11, 2018

There is now a solution for this problem in react-native-fs. Enabling access and copy content:// files -itinance/react-native-fs#395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants