Is there an existing issue for this?
Describe the bug
.NET 10, ReadNextSectionAsync has bug,when postman submit single file throw System.IO.InvalidDataException:“The stream exceeded the data limit 16384.”, when postman submit 1+ files, ReadNextSectionAsync never return null。
protected override async Task<IReadOnlyList?> HandleAsync(
HttpRequest request,
CancellationToken token = default)
{
if (!MediaTypeHeaderValue.TryParse(request.ContentType, out var mediaTypeHeader) ||
string.IsNullOrWhiteSpace(mediaTypeHeader.Boundary.Value))
throw HttpApiExceptions.BadRequest($"Content-Type is form-data, but boundary not found");
var boundary = HeaderUtilities.RemoveQuotes(mediaTypeHeader.Boundary).Value ?? throw HttpApiExceptions.BadRequest($"Content-Type is form-data, but boundary not found");
var reader = new MultipartReader(boundary, request.Body);
var section = await reader.ReadNextSectionAsync(token);
var hasWebBlob = false;
var storageOptions = BlobStorageService.Options;
var webBlobs = new Lazy<List>(() => new List(storageOptions.MaxFilesPerTime));
while (section != null)
{
var disposition = section.GetContentDispositionHeader();
if (disposition != null &&
disposition.IsFileDisposition() &&
!string.IsNullOrWhiteSpace(disposition.FileName.Value))
{
var fileSection = section.AsFileSection();
if (fileSection?.FileStream is null) continue;
var fileType = Path.GetExtension(disposition.FileName).ToString();
if (!storageOptions.IsFileTypePermitted(fileType))
throw HttpApiExceptions.BadRequest($"Illegal file type:{fileType}");
// handle file upload
}
// .NET 10, ReadNextSectionAsync has bug,when postman submit single file throw System.IO.InvalidDataException:“The stream exceeded the data limit 16384.”, when postman submit 1+ files, ReadNextSectionAsync never return null。
section = await reader.ReadNextSectionAsync(token);
}
return hasWebBlob ? webBlobs.Value : null;
}
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response