I'm currently using react-native-aws3 and React-Native-Camera to upload images to AWS S3 since with this package, I did not have to write any native code. If there are any other suggestions around this issue that does not involve writing native code, please let me know.
Anyways, I'm having trouble uploading images to S3 when I am simulating on Android. On iOS, I have no troubles at all.
Note: As for versions, I am currently using:
{
"react-native": "0.43.0",
"react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git",
"react-native-aws3": "0.0.8",
}
Here's my code:
takePicture() {
this.camera.capture()
.then((data) => {
this.setState({ path: data.path })
const file = {
uri: data.path,
name: `${uuid.v1()}.jpg`,
type: 'image/jpeg',
};
const options = {
keyPrefix: 'photos/',
bucket: 'accountabilibuddy-1',
region: 'us-west-1',
accessKey: AWSAccessKeyId,
secretKey: AWSSecretKey,
successActionStatus: 201
};
RNS3.put(file, options).then(response => {
if (response.status !== 201) {
throw new Error('Failed to upload image to S3', response);
}
this.props.pictureTaken(response.body.postResponse.location) // reduxAction here(don't mind)
}).catch(err => console.error('Camera error not uploaded: ', err))
})
.catch(err => console.error(err));
}
For the inner catch, I am getting the following error:
For the outer catch, I am getting the following error:
Has this library worked for others on Android and/or are there any other suggestions on how to upload images to S3 to react-native without diving into the native code?
Thanks in advance for your time and patience.