Open sulagarde opened 5 years ago
I'm also having issues uploading to AWS s3 with the fetch after upgrading RN to 0.59.x. The issue here is that CameraRoll.saveToCameraRoll returns URI that is prefixed with ph:// instead of assets-library://, as the result the RNFetchBlob.fetch('PUT',.. does not return any error, but uploads 0 bytes.
I don't have any experience in native side of development for iOS but I've tracked down that react-native changed the way uri is formatted in 0.59.x
and above versions.
Pre 0.59 code: https://github.com/facebook/react-native/blob/0.58-stable/Libraries/CameraRoll/RCTCameraRollManager.m#L202
0.59+ code: https://github.com/facebook/react-native/blob/master/Libraries/CameraRoll/RCTCameraRollManager.m#L131
Yep, this seems to be correct. So, is it going to be addressed by the rn-fetch-blob? Because as of now, I can not use it with rn 0.59.x.
rn-fetch-blob is no longer maintained and won't receive any updates by the looks of it.
You can get around it by doing something like this but I don't imagine its very robust
uri = ph://9F983DBA-EC35-42B8-8773-B597CF782EDD/L0/001
ext = 'jpg'; // or heic or png etc
uri = uri.replace('ph://', '');
localIdentifier = uri.split('/')[0]; // leaves 9F983DBA-EC35-42B8-8773-B597CF782EDD
filePath = `assets-library://asset/asset.${ext}?id=${localIdentifier}&ext=${ext}`; // this you can pass into rn-fetch-blob stuff
This isn't my fix but it seems to at least work for now
Thank you for your reply, really appreciate it. And this is very unfortunate news, because I was only able to get AWS upload to work correctly with rn-fetch-blob . I wonder, what are the other alternatives people use these days for this kind of stuff. Thanks.
rn-fetch-blob is no longer maintained and won't receive any updates by the looks of it.
You can get around it by doing something like this but I don't imagine its very robust
uri = ph://9F983DBA-EC35-42B8-8773-B597CF782EDD/L0/001 ext = 'jpg'; // or heic or png etc uri = uri.replace('ph://', ''); localIdentifier = uri.split('/')[0]; // leaves 9F983DBA-EC35-42B8-8773-B597CF782EDD filePath = `assets-library://asset/asset.${ext}?id=${localIdentifier}&ext=${ext}`; // this you can pass into rn-fetch-blob stuff
This isn't my fix but it seems to at least work for now
@samparmenter Why rn-fetch-blob won't receive any update ?
@samparmenter Why rn-fetch-blob won't receive any update ?
see #359
rn-fetch-blob is no longer maintained and won't receive any updates by the looks of it.
You can get around it by doing something like this but I don't imagine its very robust
uri = ph://9F983DBA-EC35-42B8-8773-B597CF782EDD/L0/001 ext = 'jpg'; // or heic or png etc uri = uri.replace('ph://', ''); localIdentifier = uri.split('/')[0]; // leaves 9F983DBA-EC35-42B8-8773-B597CF782EDD filePath = `assets-library://asset/asset.${ext}?id=${localIdentifier}&ext=${ext}`; // this you can pass into rn-fetch-blob stuff
This isn't my fix but it seems to at least work for now
Has this worked for anyone? Trying to copy a file with cp
where the source file being an assets-library path results in an empty file to the destination path.
For what is worth using react-native-fs with copyAssetsFileIOS
and formatting the path with the above code snippet seems to work. I guess there's most probably an issue with rn-fetch-blob itself.
Since I upgraded react-native 0.59.1 I cannot get stats from iOs files: Error: failed to stat path ph://9F983DBA-EC35-42B8-8773-B597CF782EDD/L0/001 because it does not exist or it is not a folder.