java - Amazon S3 连接返回错误请求
问题描述
部署后我已经成功连接。经过 4 小时的部署(大约),出现了一些连接问题。来自 S3 的错误是
com.amazonaws.services.s3.model.AmazonS3Exception: Bad Request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad Request; Request ID: ABCD; S3 Extended Request ID:ABCD=)
亚马逊客户端创建代码
public AmazonS3Client getAmazonS3Client() {
AmazonS3Client s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain().getCredentials());
s3Client.setRegion(Region.getRegion(Regions.US_WEST_2));
return s3Client;
}
我完全被这个困住了。有人可以帮忙吗。
解决方案
试试这个,这就是我正在使用的,它工作正常:
private AmazonS3 getClient() {
return AmazonS3ClientBuilder.standard()
.withCredentials(new DefaultAWSCredentialsProviderChain())
.withRegion(Regions.EU_CENTRAL_1)
.build()
}
推荐阅读
- symfony - Symfony3.4 独白包未写入自定义频道文件
- python - Celery:如何自定义多处理池初始化?
- java - 在 android 中转到应用程序的特定部分
- python - 从代码单元跳转到特定代码单元(即以编程方式)(jupyter / ipython)
- spring - Spring:如何在JSP中获取模型属性并检查它是否为空?
- react-native - 使用 asyncstorage 对本机更改状态做出反应
- java - 在android中更改两个模块的包名的问题
- image-processing - 我如何将 64 x 64 像素图像划分为 3 × 3 重叠区域(重叠大小为 14 像素)
- vb.net - vb.net 和 ms access 2016 登录表单
- python - 在python中填充数组