aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

Putting files with multiple consecutive "/" in the key fails

Open stephenfenech-nosto opened this issue 13 years ago • 3 comments

If you try to put a file with multiple "/" in the key (for example "bla//bla") fails. Tried using the 1.4.7 release as well which suggests that an issue with the keys got fixed but it fails as well. This was working ok with 1.3.5.

The following is a test which fails

    @Test
    public void test() throws FileNotFoundException, IOException {
        String bucket = "some-bucket";
        String key = "some//path";
        File target = new File("someFile.txt");
        assertTrue(target.exists());
        ObjectMetadata meta = null;
        try{
            meta = s3Client.getObjectMetadata(bucket, key);
        }catch (Exception e) {
            meta = new ObjectMetadata();
        }
        PutObjectRequest putRequest = new PutObjectRequest(bucket, key, target);
        putRequest.setMetadata(meta);
        s3Client.putObject(putRequest);
    }

The exception message is: A com.amazonaws.services.s3.model.AmazonS3Exception has been caught, The request signature we calculated does not match the signature you provided. Check your key and signing method.

The "relevant" stacktrace:

AmazonS3Exception: Status Code: 403, AWS Service: Amazon S3, AWS Request ID: ####, AWS Error Code: SignatureDoesNotMatch, AWS Error Message: The request signature we calculated does not match the signature you provided. Check your key and signing method., S3 Extended Request ID: ###
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:659)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:347)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199)
    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2994)
    at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1174)
    at my.Test.test(my.Test.java:60)

If you change the key from "some//path" to "some/path" then the test works. If you add more /s for example "some///path" it fails as well.

Hope this is detailed enough.

stephenfenech-nosto avatar Jun 26 '13 11:06 stephenfenech-nosto

Hi, stephen,

Thanks a lot for your reporting this issue and these information!

Would you please send us the wire log?

Best,

Yifei

yifeireplay avatar Jun 26 '13 23:06 yifeireplay

Just a quick update on this, we have reproduced this issue and should have the fix in the next release.

wmatveyenko avatar Sep 24 '13 23:09 wmatveyenko

This bug has been fixed in 1.5.8 version.

hanshuo-aws avatar Sep 27 '13 22:09 hanshuo-aws