Skip to content

Commit

Permalink
Fix #3201: Default to nonseekable stream upload if length is 0 or less (
Browse files Browse the repository at this point in the history
#1114)

* fix: fixes issue #3201. Default to nonseekable stream upload if the length is set to 0 by microsoft if the length is set to 0 by microsoft due to unknown length or incorrect configuration
  • Loading branch information
peterrsongg authored Oct 30, 2024
1 parent 7e092f3 commit be51d23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions generator/.DevConfigs/cce73f4a-c114-455b-b300-6377e7df4f80.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Fixes issue [#3201](https://github.com/aws/aws-sdk-net/issues/3201). Provides workaround for uploading nonseekable streams where the length may be set to 0. In Net7+ some nonseekable streams will have their length set to 0 rather than throwing a NotSupportedException or having their length correctly populated. This provides a workaround for those scenarios."
]
}
]
}
2 changes: 1 addition & 1 deletion sdk/src/Services/S3/Custom/Transfer/TransferUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ bool IsMultipartUpload(TransferUtilityUploadRequest request)
//If the length is -1 that means when we tried to get the ContentLength, we caught a NotSupportedException
//or it means the length is unknown. In this case we do a multpartupload. If we are uploading
//a nonseekable stream and the ContentLength is more than zero, we also do a multipart upload.
if (request.ContentLength == -1 && request.InputStream != null && !request.InputStream.CanSeek)
if (request.ContentLength <= 0 && request.InputStream != null && !request.InputStream.CanSeek)
{
return true;
}
Expand Down

0 comments on commit be51d23

Please sign in to comment.