ByteRange is not working in IAmzonS3.GetObjectAsync #2523
-
Describe the bugI am processing a very huge file from S3 hence want to process it by byte chunks.
Here I would expect content Debug logs :AsyncCall = True; CanonicalRequest = GET\n/data.txt\n\nhost:app-test-bucket.s3.amazonaws.com\nrange:bytes=1000-\nuser-agent:aws-sdk-dotnet-coreclr/3.7.101.15 aws-sdk-dotnet-core/3.7.100.15 .NET_Core/6.0.10 OS/Microsoft_Windows_10.0.14393 ClientAsync\nx-amz-content-sha256:XXXXX\nx-amz-date:20230117T085013Z\nx-amz-security-token:XXXXX\n\nhost;range;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token\XXXXX; StringToSign = AWS4-HMAC-SHA256\n20230117T085013Z\n20230117/us-east-1/s3/aws4_request\nXXXXXXX; ServiceName = AmazonS3; ServiceEndpoint = https://app-test-bucket.s3.amazonaws.com/; MethodName = GetObjectRequest; Exception = Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.\r\n at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)\r\n at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.RedirectHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.S3.Internal.AmazonS3ResponseHandler.InvokeAsync[T](IExecutionContext executionContext)\r\n at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext); StatusCode = Forbidden; AmzId2 = XXXXXX; AWSRequestID = WBHD681WVR5ZNCAF; AWSErrorCode = SignatureDoesNotMatch; CredentialsRequestTime = 00:00:00.0030147; RequestSigningTime = 00:00:00.0384433; HttpRequestTime = 00:00:02.0419348; ClientExecuteTime = 00:00:02.405368 Expected BehaviorHere I would expect content s3Response.ContentLength to be set to Current Behavior
Reproduction StepsSend the request and you will see an error.
Possible SolutionNo response Additional Information/ContextNo response AWS .NET SDK and/or Package version usedAWSSDK.S3.3.7.101.15 Targeted .NET Platform.NET 6 Operating System and versionWindows 10 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
@ElectricVampire Thanks for opening the issue. Upon analysis, it appears that if you don't specify the upper bound, it defaults from the starting byte to the end byte of the object. For instance, the below code: using Amazon.S3;
using Amazon.S3.Model;
var _clientAmazonS3 = new AmazonS3Client();
var downloadRequest = new GetObjectRequest()
{
Key = "<<some-key>>",
BucketName = "<<some-bucket>>",
ByteRange = new ByteRange("bytes=1000-")
};
GetObjectResponse s3Response = await _clientAmazonS3.GetObjectAsync(downloadRequest);
Console.WriteLine($"Content Length: {s3Response.ContentLength}, Content Range: {s3Response.ContentRange}"); returns
If we change the var downloadRequest = new GetObjectRequest()
{
Key = "<<some-key>>",
BucketName = "<<some-bucket>>",
ByteRange = new ByteRange(0, 1000)
}; it returns:
This is correct. So in your case, you are requesting starting with byte Also, I'm not getting any signature mismatch error while executing the above code. Hope this provides explanation for your use case. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
@ElectricVampire Thanks for opening the issue. Upon analysis, it appears that if you don't specify the upper bound, it defaults from the starting byte to the end byte of the object. For instance, the below code:
returns
s3Response.ContentRange
asbytes 1000-…