Ajmal Muhammad
Ajmal Muhammad

Reputation: 695

Amazon S3 connection returns Bad Request

I have got a successful connection after deployment. After 4 hours of deployment(approx), there were some connection issues. Error from S3 is

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=)

Amazon client creation code

public AmazonS3Client getAmazonS3Client() {
        AmazonS3Client s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderChain().getCredentials());
        s3Client.setRegion(Region.getRegion(Regions.US_WEST_2));
        return s3Client;
}

I am totally stuck with this one. Could someone please help.

Upvotes: 0

Views: 1168

Answers (1)

drake
drake

Reputation: 111

Try this, that's what I'm using and it works fine:

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

Upvotes: 1

Related Questions