If S3Client.getObject() with range is called, GetObjectRequest.contentRange() should return value of Content-Range header (e.g. "bytes 100-200/1000").
GetObjectRequest.contentRange() always returns null.
'x-amz-content-range' header contains the desired value.
Populate contentRange field by 'x-amz-content-range' header instead of 'Content-Range' header.
String bucketName = "specify your bucket";
String key = "specify your object's key";
GetObjectRequest getObjectRequest = GetObjectRequest.builder()
.bucket(bucketName)
.key(key)
.range("bytes=2-3")
.build();
GetObjectResponse response = s3Client.getObject(getObjectRequest).response();
assertNotNull(response.contentRange()); // -> fails
Here is the behavior I observed:
1) when x-amz-te: append-md5 header is sent in the request, the response is 200 OK and content range is returned in x-amz-content-range header
2) when x-amz-te: append-md5 header is not present in request, respone is 206 Partial Content and range is returned in Content-Range header.
SDK only looks for Content-Range header in the response. As all requests in v2 sdk contain x-amz-te: append-md5 header, there is no Content-Range header and response.contentRange() is null.
I am not sure why there is difference in behavior. I will internally cut a ticket to S3 team and proceed based on the discussion.
Hey @varunnvs92 :)
Is there some update or is it still under investigation?
I'm still seeing this issue, has there been any progress on the internal ticket? @varunnvs92
@itsbriantruong Research has resumed. Sorry about the delay.
This will be fixed with the next SDK release. We'll attempt to keep chasing this issue down service-side, but there's no reason to let it linger since we can cover it up for now on the client side.
Hi @millems I'm also kinda stuck with this issue for now, and don't see a solution or workaround to make it work. Maybe I'm missing something or just don't get what you mean by cover it up on the client side?
@AlexJays2 If you update to the latest S3 SDK version, we now "cover up" the service-side bug by copying the value to the proper field on their behalf.
Let me know if you're still having this issue in the latest SDK version.
Hi @millems thank you for the super fast reply :) I'm currently using version 2.13.37 and experiencing this issue
/// Edit:
To round it up:
Local environment
OS: Ubuntu Focal Fossa 20.04
JDK: 11.0.7
and using the S3AsyncClient
@millems it was a dependency issue. I'm sorry fro bothering you.