Description
Describe the bug
We've recently updated the AWSSDK.S3 NuGet package from version 3.7.310.1 to version 3.7.413, but this causes the PutObjectAsync
method to hang for some time and then throw an AmazonS3Exception
with message Error making request with Error Code InternalServerError and Http Status Code InternalServerError. No further error information was returned by the service.
We can see the object are uploaded to the S3 bucket.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
The files are uploaded and the method is returning a Task<PutObjectResponse>
Current Behavior
The files are uploaded and the method is hanging for a long time, and then throws an AmazonS3Exception
with message Error making request with Error Code InternalServerError and Http Status Code InternalServerError. No further error information was returned by the service.
Reproduction Steps
using Amazon.S3;
using Amazon.S3.Model;
using Microsoft.AspNetCore.Mvc;
namespace Backend.Controllers.ImageController;
[Route("api/[controller]")]
public class ImageController : ControllerBase
{
private readonly IAmazonS3 _s3Client;
public ImageController(IAmazonS3 s3Client)
{
_s3Client = s3Client;
}
public class UploadImageDto
{
public required IFormFile Image { get; set; }
}
[HttpPost("upload-image")]
public async Task<ActionResult> UploadImage([FromForm] UploadImageDto dto)
{
using var memoryStream = new MemoryStream();
await dto.Image.CopyToAsync(memoryStream);
var request = new PutObjectRequest
{
BucketName = "my-bucket",
Key = "my-folder/my-image.jpeg",
ContentType = "image/jpeg",
InputStream = memoryStream,
};
await _s3Client.PutObjectAsync(request);
return Ok();
}
}
Possible Solution
No response
Additional Information/Context
Our workaround for now is to use AWSSDK.S3 3.7.310.1
AWS .NET SDK and/or Package version used
AWSSDK.S3 3.7.413
Targeted .NET Platform
.NET 8
Operating System and version
OSX Sequoia 15.3