gpt4 book ai didi

amazon-web-services - 将文件上传到 Amazon S3 时出现访问被拒绝错误

转载 作者:行者123 更新时间:2023-12-02 03:15:28 25 4
gpt4 key购买 nike

获取访问被拒绝错误:

Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: AEB65D41FEB958C7; S3 Extended Request ID: jhCxO/Mv4MTxMRjvkM3bHVJ3dhb7TBeK0k7qHFUY3Q/RFhF591mRLeIzPXUEF0EdtgX9FNJXSq4=), S3 Extended Request ID: jhCxO/Mv4MTxMRjvkM3bHVJ3dhb7TBeK0k7qHFUY3Q/RFhF591mRLeIzPXUEF0EdtgX9FNJXSq4=File Upload Exception:Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: AEB65D41FEB958C7;

尝试上传文件时。我的代码是:

private void uploadFile(String fileName, File file) {
System.out.print("clouldfileservice: putREqeust");
PutObjectRequest request = new PutObjectRequest(this.bucketName, fileName, file)
.withCannedAcl(CannedAccessControlList.PublicRead);
try {
PutObjectResult result = this.s3Client.putObject(request);
} catch (Exception e) {
System.out.print("File Upload Exception:" + e.toString());
System.out.print("File Upload Exception:" + e.getLocalizedMessage());

}

}

最佳答案

错误表明您无权访问 S3 存储桶。

正确的解决方案:

转到policy generator并生成一个,它是一个配置,定义谁有权访问该资源。

将该策略粘贴到存储桶设置> 权限> 存储桶策略并保存。

快速而肮脏的解决方案:

选中“列表”和“写入”复选框:存储桶设置> 权限> 公共(public)访问> 所有人.

转至:存储桶设置> 权限> 存储桶策略

关于amazon-web-services - 将文件上传到 Amazon S3 时出现访问被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56299192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com