我在尝试使用AWS S3高级API客户端时遇到了问题。我使用的代码与AWS示例文档(www.example.com)中描述的代码几乎相同https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/dotnetv3/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
,所以我很困惑我所面临的确切问题是什么。
软件开发工具包: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);
1条答案
按热度按时间wbgh16ku1#
我忘了说我使用的是其他供应商(不是AWS)提供的存储,它支持AWS S3 API。不幸的是,目前它确实不支持分块上传。
GitHub问题-https://github.com/aws/aws-sdk-net/issues/2526#issuecomment-1403700805