403 forbidden error for Amazon S3 upload (PUT) via signedUrl in React

Viewed 514

I am trying to upload to AWS S3 using signedUrl in React: I get a 403 error even though the user has the permission to upload (permissions are set in the user's group, Cors config and Bucket Policy)

The main upload code is as follows:

      var options = {
        headers: {
          'Content-Type': fileType
        }
      };

      axios.put(signedRequest,file,options)
      .then(result => {
        this.setState({success: true});
      })
      .catch(error => {
        console.log("Line 214: ERROR " + JSON.stringify(error));
      })

I created the signedUrl on the back end using PHP:

$cmd = $s3Client->getCommand('GetObject', 
   [ 'Bucket' => <bucket>,
     'Key' => <key> 
]); 
$request = $s3Client->createPresignedRequest($cmd, '+120 minutes'); 
$presignedUrl = (string) $request->getUri();
0 Answers
Related