簡體   English   中英

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

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

我在嘗試使用 AWS S3 高級 API 客戶端時遇到問題。 我使用的代碼與 AWS 示例文檔中描述的代碼幾乎相同 - https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/do.netv3/S3/TrackMPUUsingHighLevelAPIExample/TrackMPUUsingHighLevelAPI.cs #L48

唯一不同的是客戶端創建,因為我出於測試目的手動設置它:

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

但是,插入文件時出現以下異常:

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)

我沒有在任何地方明確設置aws-chunked ,所以我很困惑我面臨的確切問題是什么。

SDK: AWSSDK.S3 3.7.101.59
目標框架: net6.0

我嘗試以下列方式使用PutObjectRequest上傳文件,一切都對我有用:

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

我忘了提到我正在使用其他供應商(不是 AWS)提供的存儲產品,它支持 AWS S3 API。 不幸的是,目前它確實不支持分塊上傳。

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