react-native-s3 icon indicating copy to clipboard operation
react-native-s3 copied to clipboard

[Android] uri with content://com.... give `Invalid file`-error

Open proProbe opened this issue 8 years ago • 3 comments

Im currently using this library in conjuction with react-native-image-picker. When choosing a video on android phones, the uri given is of the format content://com.google.android.apps.photos.contentprovider/-1/2/content%3A%2F%2Fmedia%2Fexternal%2Ffile%2F1061/ORIGINAL/NONE/1578050655. react-native-s3 then throws an error of Invalid file. Using react-native-aws3 doesnt give this error and it uploads correctly. Im migrating over to this library as it has backgroundupload! So I would love to know how to solve this problem.

proProbe avatar Feb 17 '17 10:02 proProbe

I believe that the https://github.com/mybigday/react-native-s3/blob/master/android/src/main/java/com/mybigday/rns3/RNS3TransferUtility.java#L237 can't handle URI:s with conten:// in it? Im not sure though as I dont really know android java

proProbe avatar Feb 17 '17 13:02 proProbe

@proProbe Had the same issue. My fix was to use response.path for Android and response.uri for iOS.

See: https://github.com/react-community/react-native-image-picker#the-response-object

rpastorelle avatar Aug 09 '17 20:08 rpastorelle

Another thing on top of using response.path for Android, is that the path should be preceded by file://. So it looks something like: file://storage/emulated/0/Download/828.jpg

azanli avatar Jul 13 '18 22:07 azanli