简体   繁体   中英

AWS S3 Multipart file upload issue using TransferUtility (aws-chunked is not supported) in .NET 6

I have faced issue while trying to use AWS S3 High-Level API client. The code I am using is pretty much the same as described in AWS example docs - https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/do.netv3/S3/TrackMPUUsingHighLevelAPIExample/TrackMPUUsingHighLevelAPI.cs#L48

The only thing that is different is client creation as I am setting that manually for testing purposes:

var configuration = new AmazonS3Config
{
   ForcePathStyle = true,
   ServiceURL = "URL",
};
var credentials = new BasicAWSCredentials("ACCESS_KEY", "SECRET");
IAmazonS3 client = new AmazonS3Client(credentials, configuration);

However, when inserting file I am getting following exception:

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      Amazon.S3.AmazonS3Exception: Transfering payloads in multiple chunks using aws-chunked is not supported.
       ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
         at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
         at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.Runtime.Internal.RedirectHandler.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.S3.Internal.AmazonS3ResponseHandler.InvokeAsync[T](IExecutionContext executionContext)
         at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)

I am not explicitly setting aws-chunked anywhere, so I am confused what is the exact issue I am facing.

SDK: AWSSDK.S3 3.7.101.59
Target framework: net6.0

I have tried uploading file using PutObjectRequest in following way and everything works for me:

 fs.Seek(0, SeekOrigin.Begin);
 var uploadRequest = new PutObjectRequest
 {
    InputStream = fs,
    Key = outputFileName,
    BucketName = bucketName,
    UseChunkEncoding = false,
 };
 await _client.PutObjectAsync(uploadRequest);

I forgot to mention that I am using storage offering from other vendor (not AWS), which supports AWS S3 APIs. Unfortunately, for now it does not support chunked uploads indeed.

GitHub issue - https://github.com/aws/aws-sdk.net/issues/2526#issuecomment-1403700805

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM