Report this

What is the reason for this report?

Can't use Spaces via Amazon S3 SDK

Posted on February 10, 2018

I’m trying to perform a PUT operation towards Spaces using AWS S3 Java SDK, but I keep getting the same error.

Here’s the definition of the client:

    public AmazonS3 spaces() {
        BasicAWSCredentials credentials = new BasicAWSCredentials(...);
        return AmazonS3ClientBuilder.standard().
                withCredentials(new AWSStaticCredentialsProvider(credentials)).
                withPathStyleAccessEnabled(true).
                withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("bucketname.ams3.digitaloceanspaces.com", "ams3")).
                build();
    }

Here’s usage:

spaces.putObject("bucketname", fullPath, tempFile);

And the error is:

com.amazonaws.services.s3.model.AmazonS3Exception: Bad request (Service: Amazon S3; Status Code: 400; Error Code: 400 Bad request; Request ID: null; S3 Extended Request ID: null)

SDK version:

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>1.11.274</version>
        </dependency>

I tried to replace AwsClientBuilder.EndpointConfiguration("bucketname.ams3.digitaloceanspaces.com", "ams3") with AwsClientBuilder.EndpointConfiguration("ams3.digitaloceanspaces.com", "ams3"), but it also didn’t work.

And when I try to GET the file, I surprisingly get a different error:

com.amazonaws.services.s3.model.AmazonS3Exception: null (Service: Amazon S3; Status Code: 403; Error Code: SignatureDoesNotMatch; Request ID: ...; S3 Extended Request ID: ...)

Although I’m pretty sure that I’ve specified key and secret correctly: I double-checked it.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I am facing the same problem, Did anyone resolve this or Digital Ocean is not sure about the solution?

I am facing the same issue with AWS SDK: 1.11.528

(surprisingly after almost one and half years this is still not resolved)

Maybe a better strategy is not to claim DO spaces are S3 compatible.

I know that the question is old but I faced the same issue and RESOLVED it. In my case, the problem was on the wrong date. The date was set up a few days in the future and I had the issue. After I put the correct date/time everything works fine :-)

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.