首页 > 解决方案 > 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;
}

我完全被这个困住了。有人可以帮忙吗。

标签: javaspringamazon-web-servicesamazon-s3

解决方案


试试这个,这就是我正在使用的,它工作正常:

private AmazonS3 getClient() {
    return AmazonS3ClientBuilder.standard()
        .withCredentials(new DefaultAWSCredentialsProviderChain())
        .withRegion(Regions.EU_CENTRAL_1)
        .build()
}

推荐阅读