Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 403通过React中的signedUrl上传Amazon S3(PUT)时禁止出现错误_Reactjs_Amazon S3_Upload_Http Status Code 403 - Fatal编程技术网

Reactjs 403通过React中的signedUrl上传Amazon S3(PUT)时禁止出现错误

Reactjs 403通过React中的signedUrl上传Amazon S3(PUT)时禁止出现错误,reactjs,amazon-s3,upload,http-status-code-403,Reactjs,Amazon S3,Upload,Http Status Code 403,我正在尝试使用React中的signedUrl上传到AWS S3: 即使用户有上传权限,我也会收到403错误(权限在用户的组、Cors配置和Bucket策略中设置) 主要上传代码如下: var options = { headers: { 'Content-Type': fileType } }; axios.put(signedRequest,file,options) .then(resul

我正在尝试使用React中的signedUrl上传到AWS S3: 即使用户有上传权限,我也会收到403错误(权限在用户的组、Cors配置和Bucket策略中设置)

主要上传代码如下:

      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));
      })
我使用PHP在后端创建了signedUrl:

$cmd = $s3Client->getCommand('GetObject', 
   [ 'Bucket' => <bucket>,
     'Key' => <key> 
]); 
$request = $s3Client->createPresignedRequest($cmd, '+120 minutes'); 
$presignedUrl = (string) $request->getUri();
$cmd=$s3Client->getCommand('GetObject',
[‘Bucket’=>,
“键”=>
]); 
$request=$s3Client->createPresignedRequest($cmd,+120分钟);
$presignedUrl=(字符串)$request->getUri();

您是如何生成已签名的url的?您也在使用v4签名吗?我使用:$cmd=$s3Client->getCommand('GetObject',['Bucket'=>'Key'=>])创建它$请求=$s3Client->createPresignedRequest($cmd,+120分钟)$presignedUrl=(字符串)$request->getUri();我用代码更新了帖子。