-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Read file from Camera roll (content:// path on android) #287
Comments
I'm seeing the same thing for
Android, RN 0.42. |
I just found this today. So that's a +1 from me. Same error pops up, and get's caught in the promise. Should mention I'm using the readFile(uri, 'base64') version. |
Thanks for providing the information, will look into this issue ASAP 👍 |
After some investigation, the problem is that our Android URI resolver couldn't get the absolute file path from the given URI. I will try to figure out if there's a better implementation. |
I'm experiencing this in Android 7.1 if that makes any difference. Lmk if you'd like me to test anything. |
@ChrisPikul510 @tlvince , is there any way to make a content provider URI like In my case, the URIs from camera roll look like this |
Apologies. In my case I'd missed adding a content type prefix altogether; adding |
@wkh237 I was using https://github.com/marcshilling/react-native-image-picker to take a picture. It saves to the gallery of the phone or selects from the gallery. I can understand if you feel like 3rd party support is not on the top of your list though. I solved it by storing the base64 directly from the callback instead of getting it from the filesystem. |
@nordved , thanks for the information. It'd be great to make this kind of URI supported since it's very common use case IMO 👍 |
@wkh237 The uri I was attempting came directly from Google Drive app through a share intent. In which case from my end I'm not entirely sure exists as that looks like a hash/temp URI. Are you suggesting I modify the URI? BTW, is there a way you can implement a function for grabbing N bytes from a file? I ask because I'm only reading this file to grab the first 16 bytes to cross-reference with my list. Which also if you want to integrate here would be cool too. It's just header signature negotiation... |
@ChrisPikul510 , thanks for the information, though the function is not supported yet but it's on our roadmap (see #124). However, as a workaround, you can use an undocumented API
which will create a file at path |
@wkh237 So if I have this right, a way for me to get the header is to do something like....
And that should give me only the first 16 bytes correct? But if I have a temp file, then I'll need to unlink it, which seems a bit too complicated computationally for something so simple. Anyways, any word on the |
About the content:// URI's problem, after some investigations I got some clues. In short, we have to handle this kind of URI in a different way, will update the status once it's complete. |
I've added additional URI handling to
|
@tlvince I am having the same issue, with the same image picker. How did you do it in the end? Is this the line you updated? |
@wkh237 Just tried it, it doesn't seem to fix my issue. Below is the URI I am using in |
@etiennewaldron , thanks for the feedback. Will look into the issue and find another possible solution. |
Hi, do you have any news on this issue? Is there a quick fix I can use in the meantime? Thanks |
@etiennewaldron , I've just updated branch
Please try if that works, thanks 👍 |
not working on 0.10.6, and issue-287 gives me path == |
Just updated branch |
@wkh237 Not working on |
@wkh237 I have updated my package to branch 287 kindly help me in solving this issue |
@ShoaibKhazer , is there steps to reproduce the error? Including the app you use to select the image. |
I am simply using react-native image picker to capture the image
|
@wkh237 your response is highly valuable as my product is about to launch :) |
@ShoaibKhazer , I'd like to help but I will need to find a way to get the problematic URI. I've tested the URIs I can have, and could not reproduce the error. Have you tried android.getContent for getting images/files ? |
fix problem with settings
|
@ShoaibKhazer , great to know it's working ! Also thanks @maiordom for the help 😗 |
@wkh237 I am using If I specify
react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java Lines 904 to 919 in a8cfeb1
Also I noticed that the constant react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobConst.java Line 11 in 50a4d06
|
Hi @wkh237 I have the same issue that @ShoaibKhazer reported. I tried as you suggested by using |
I've made it work with |
@CptMaumau It would help if you could produce a test case, especially if it is one that fits right into the already existing tests: https://github.com/wkh237/react-native-fetch-blob-dev/tree/master/test (all files starting with "test-" are tests for RNFB). |
If anyone is still having issues with this on Android, try #546 |
+1 |
There is now a solution for this problem in react-native-fs. Enabling access and copy content:// files -itinance/react-native-fs#395 |
Is this going to be merged anytime soon? Or could i use @tombailey fork? I know that the maintainer is missing, but this is a huge drawback. Is there anything left to do on issue-287 branch? |
Using react native image picker wrapped |
Thanks @maiordom for the help |
in my case, it was only happening on android and with additional data. my additional data had ID in it, which is an integer.. so simply adding this ->
fixed it.. |
I am trying to get the base64 code for an image in the camera roll. The path for the image is something like
And I am trying to read this file with
and
The app simply crashes and in the logcat I can find the error
I have also tried
Which gives the error:
In the FileSystem API you write that it is possible to read the files from
content://
, so I'd like to know if there is another way that I'm not seeing.EDIT: I'm using RN 0.41 and RNFB 0.10.2
The text was updated successfully, but these errors were encountered: