I'm using the aws-amplify library to upload images from devices to aws amplify storage. My config is :
Amplify.configure({
Auth: {
identityPoolId: 'xxxxxxxxxxxxxxxx',
region: 'xxxxxxxx',
userPoolId: 'xxxxxxxxxxxx',
userPoolWebClientId: 'x'
},
Storage: {
AWSS3: {
bucket: 'xxxxx-name',
region: 'xxxxxxxx',
}
}
});
and the Storage.put Method for uploading files.
On the browser, it works perfect, i can upload images.
But from the device (Android emulator) with cordova-plugin-camera it throws a cannot read property 'bytelength' of undefined.
Here is code used for mobile devices :
navigator.camera.getPicture(
data => {
Storage.put("test.jpeg", dataConvertedToBlob).then((res) => {
this.imageSrc = res.toString();
});
},
(err) => { // on fail
console.error('Could not access device camera.');
},
{
quality: 100,
destinationType: Camera.DestinationType.DATA_URL,
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.CAMERA,
mediaType: Camera.MediaType.PICTURE,
cameraDirection: Camera.Direction.BACK,
}
})
I tried a lot of convertion methods like sending to the put method blob, convert image to javascript File, sending base64 data, none of them worked on device
Any ideas ?