smallzZz8
smallzZz8

Reputation: 101

How to upload image to AWS S3 from React Native? Error 403

So I am trying to upload an image to S3 from my React Native code but I am getting a 403 error? I have amplify and have connected it to a user that has admin permissions but it is still not working.

import Amplify from 'aws-amplify';
import { Storage } from 'aws-amplify';

Storage.put('test.txt', 'Hello')
            .then (result => console.log(result))
            .catch(err => console.log(err));

And my configure is: enter image description here

And the error that I am getting is: enter image description here

Upvotes: 1

Views: 490

Answers (1)

Jignesh Mayani
Jignesh Mayani

Reputation: 7193

Have a try by adding the contentType at the time of uploading the file.

Storage.put('test.txt', 'Private Content', {
    level: 'private',
    contentType: 'text/plain'
})
.then (result => console.log(result))
.catch(err => console.log(err));

Upvotes: 1

Related Questions