You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用.NET S3 API上传Base64图片至Cloudflare R2时遭遇STREAMING-AWS4-HMAC-SHA256-PAYLOAD未实现错误的问题求助

.NET S3 API上传Base64图片至Cloudflare R2时遭遇STREAMING-AWS4-HMAC-SHA256-PAYLOAD未实现错误的问题求助

大家好,我最近在做一个功能:用Angular网站上传图片,然后把图片传到我的.NET REST API,再通过S3兼容的API把Base64格式的图片上传到Cloudflare R2。但是现在遇到了一个错误,折腾了好久都没解决,想请教下各位大佬。

先给大家看看我的.NET API代码:

[Route("api/[controller]")]
[Authorize]
[ApiController]
public class FileController : ControllerBase
{
    private static IAmazonS3 s3Client;

    public FileController()
    {
        string accesKey = <<accesKey>>;
        string secretKey = <<secretKey>>;
        BasicAWSCredentials credentials = new BasicAWSCredentials(accesKey, secretKey);
        s3Client = new AmazonS3Client(credentials, new AmazonS3Config {
            ServiceURL = <<serviceURL>>,
        });
    }

    [HttpPost("{fileName}")]
    [AllowAnonymous]
    public string uploadFile(string fileName, base64ImageDTO base64Image)
    {
        try
        {
            byte[] bytes = Convert.FromBase64String(base64Image.base64String);
            using (s3Client)
            {
                var request = new PutObjectRequest
                {
                    BucketName = <<bucketName>>,
                    CannedACL = S3CannedACL.PublicRead,
                    Key = fileName,
                };
                using (var ms = new MemoryStream(bytes))
                {
                    request.InputStream = ms;
                    var response = s3Client.PutObjectAsync(request);
                }
            }
        }
        catch(Exception ex)
        {
            Console.WriteLine("aws fail");
        }
        return "";
    }
}

运行后抛出的错误信息是这样的:

Amazon.S3.AmazonS3Exception: STREAMING-AWS4-HMAC-SHA256-PAYLOAD not implemented
---> 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)

我排查了好一会儿,还是没找到问题所在,有没有人能帮我看看哪里出错了?

备注:内容来源于stack exchange,提问作者Olivier De Brabant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:43:10