URL encoding of bucket name - change in 1.12.460 #2976
Replies: 5 comments 5 replies
-
Since
https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html How about having the SDK apply that check to bucket name parameters and raise a descriptive error? |
Beta Was this translation helpful? Give feedback.
-
@debora-ito What happens, if the prefix has "/" and is appended with bucket earlier like "bucketName/custId/payments"? How to fix the same after upgrading the sdk version to 1.12.538? I can't able to include this "/custId/banners" in the key as well. I'm getting the access denied error when downloading the uploaded URL object. |
Beta Was this translation helpful? Give feedback.
-
Is there an equivalent AWS SDK v2 minor version we should be watching out for? |
Beta Was this translation helpful? Give feedback.
-
Btw since this is an API behavior change, shouldnt the minor version be bumped 1.12 -> 1.13? I get this is a bug, but its very old behavior, and old behavior + many years = new supported behavior 😅 . So fixing the bug should have involved a new minor version and proper changelog notes. |
Beta Was this translation helpful? Give feedback.
-
Hi, can the s3client.putObject(putObjectRequest); will work with the version sdk version 1.12.460 or later. The putObjectRequest goes like : PutObjectRequest putObjectRequest = new PutObjectRequest(directory, fileName, inputStream, metadata).withCannedAcl( |
Beta Was this translation helpful? Give feedback.
-
On 05/01/2023, Java SDK version
1.12.460
released a change to the S3 Client to perform URL encoding on the bucket name. This may break customers who currently rely on the behavior of special characters. For example, in agetObject
call, if you have the key prefix appended to the bucket name likes3Client.getObject("bucket/prefix", "key")
, the URL path of the request sent to S3 is nowGET /bucket%2Fprefix/key
instead ofGET /bucket/prefix/key
.This issue can manifest itself as a
403 SignatureDoesNotMatch
error:com.amazonaws.services.s3.model.AmazonS3Exception: The request signature we calculated does not match the signature you provided. Check your key and signing method. (Service: Amazon S3; Status Code: 403; Error Code: SignatureDoesNotMatch;)
How to fix
If you are seeing
403 SignatureDoesNotMatch
errors in calls to S3 after upgrading the SDK version to1.12.460
or later, check your request to make sure that special characters such as "/" are not part of the bucket name.Note that a key prefix should be part of the key name, and not part of the bucket name:
Don't use:
s3Client.getObject("bucket/prefix", "key")
Instead, use:
s3Client.getObject("bucket", "prefix/key")
Beta Was this translation helpful? Give feedback.
All reactions