react-native-s3
react-native-s3 copied to clipboard
[Android] uri with content://com.... give `Invalid file`-error
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.
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 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
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