Skip to content

The introduction of FormFileValueProvider broke the documented large file upload #14518

@Tragetaschen

Description

@Tragetaschen

Describe the bug

This bug tries to tie a couple of issues and provide some search terms.

#9510 and #12847 introduced FormFileValueProviderFactory in the ResourceExecutingContext's ValueProviderFactories.

On the other hand, the 2.2 documentation for streaming file upload describes which ValueProviderFactories to remove in order to make large file uploads work.

The documentation team is already updating the docs: dotnet/AspNetCore.Docs#13344

Should this be part of the breaking changes in 3.0?

To Reproduce

Run the documentation's 2.2 code on 3.0 and notice that the request fails with

System.IO.InvalidDataException: Multipart body length limit 134217728 exceeded.
   at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.UpdatePosition(Int32 read)
   at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Mvc.ModelBinding.FormFileValueProviderFactory.AddValueProviderAsync(ValueProviderFactoryContext context, HttpRequest request)
   at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ActionContext actionContext, IList`1 factories)
   at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
[…]

Expected behavior

Streaming file uploads should work.

To fix

RemoveType the FormFileValueProviderFactory in the resource filter attribute as well.

Metadata

Metadata

Assignees

Labels

DocsThis issue tracks updating documentationarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions