reactjs - 通过 React 中的 signedUrl 上传 Amazon S3 (PUT) 的 403 禁止错误
问题描述
我正在尝试在 React 中使用 signedUrl 上传到 AWS S3:即使用户具有上传权限,我也会收到 403 错误(权限在用户组、Cors 配置和存储桶策略中设置)
主要上传代码如下:
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();
解决方案
推荐阅读
- javascript - 如何使用 getElementsByClassName 调用同一类的多个元素?
- java - QueryDSL 如何将 ParamExpression 添加到 JPAQuery 以使用 EntityManager.createQuery 执行
- google-cloud-platform - Suse 公共云按需虚拟机 (VM) 无法接收更新
- javascript - React js中的网页访问计数器
- node.js - Mongoose 将对象 ID 推送到现有 mongoDB 对象的数组中
- html - 单击 Bootstrap 导航栏切换按钮不显示折叠的内容
- .net - 从现有模板创建 .NET Framework 项目命令行
- javascript - 有没有办法让用户使用 Reast.js 将图像上传到服务器?
- javascript - GraphQL 在运行时不传递根集
- c - 如何解决找不到给定编译器命令的 lapho-mqtt3c 问题?