简体   繁体   English

.NET 中使用 TransferUtility(不支持 aws-chunked)的 AWS S3 多部分文件上传问题 6

[英]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.我在尝试使用 AWS S3 高级 API 客户端时遇到问题。 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我使用的代码与 AWS 示例文档中描述的代码几乎相同 - 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.我没有在任何地方明确设置aws-chunked ,所以我很困惑我面临的确切问题是什么。

SDK: AWSSDK.S3 3.7.101.59 SDK: AWSSDK.S3 3.7.101.59
Target framework: net6.0目标框架: net6.0

I have tried uploading file using PutObjectRequest in following way and everything works for me:我尝试以下列方式使用PutObjectRequest上传文件,一切都对我有用:

 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.我忘了提到我正在使用其他供应商(不是 AWS)提供的存储产品,它支持 AWS S3 API。 Unfortunately, for now it does not support chunked uploads indeed.不幸的是,目前它确实不支持分块上传。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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