1

After picking file with react-native-document-picker like this:

const res = await DocumentPick.pick({
   type: [DocumentPick.types.allFiles],
});

I've got two types of URI depends of device (Android only):

content://media/external/images/media/31

or

content://com.android.providers.media.documents/document/image:31

I successfully use rn-fetch-blob with the first one (Adding file:// before the returned uri) but I can't with the second one:

[Error: stat error: failed to list path `content://com.android.providers.media.documents/document/document%3A31` for it is not exist or it is not a folder]

Also trying to replace %3A to ":" but I've got the same error.

So, how I can use rn-fetch-blob with URI like "content://com.android.providers.media.documents/document/image:31" ?

dcr31000
  • 33
  • 5
  • Have a look at this to get the 'real' path across devices: https://stackoverflow.com/questions/20067508/get-real-path-from-uri-android-kitkat-new-storage-access-framework – Aleksandar Zoric May 09 '22 at 08:04
  • To get the real path with React Native, I need to use rn-fetch-blob. That's exactly what I am trying to do (and that's exactly what failed with URI like com.android.providers.media.documents) – dcr31000 May 11 '22 at 07:45
  • Yeah, but did you see the answers in the above link where they have logic to split the path and return different items based on diff. versions – Aleksandar Zoric May 11 '22 at 08:25

1 Answers1

0

try setting the following in options {copyTo : "cachesDirectory" }, this will copy the file & generate an absolute path which can be accessed from fileCopyUri in response.

Zhlayzoon
  • 61
  • 3