'React Native - AWS S3 Upload Image Error: URL.hostname is not implemented
I'm trying to upload photos using React Native, AWS Amplify and S3. I'm getting the following error:
LOG [Error: URL.hostname is not implemented]
I've tried almost every method found here, and I haven't been able to come to any conclusions.
const uploadResource = async () => {
if (isLoading) return;
setisLoading(true);
const img = await fetchResourceFromURI(asset.uri);
return Storage.put(asset.uri, img, {
level: 'public',
contentType: asset.type,
progressCallback(uploadProgress) {
setProgressText(
`Progress: ${Math.round(
(uploadProgress.loaded / uploadProgress.total) * 100,
)} %`,
);
console.log(
`Progress: ${uploadProgress.loaded}/${uploadProgress.total}`,
);
},
})
.then(res => {
setProgressText('Upload Done: 100%');
setAsset(null);
setisLoading(false);
Storage.get(res.key)
.then(result => console.log(result))
.catch(err => {
setProgressText('Upload Error');
console.log(err);
});
})
.catch(err => {
setisLoading(false);
setProgressText('Upload Error');
console.log(err);
});
};
"aws-amplify": "^4.3.19",
"aws-amplify-react-native": "^6.0.4",
"react-native": "^0.68.2",
"aws-amplify": "^4.3.19",
"aws-amplify-react-native": "^6.0.4",
amazon-web-services">
amazon-web-servicesreact-nativeamazon-s3">
amazon-s3firebase-cloud-messagingapple-push-notifications
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
