Soenneker.Extensions.IFormFile
11.0.839
Prefix Reserved
dotnet add package Soenneker.Extensions.IFormFile --version 11.0.839
NuGet\Install-Package Soenneker.Extensions.IFormFile -Version 11.0.839
<PackageReference Include="Soenneker.Extensions.IFormFile" Version="11.0.839" />
<PackageVersion Include="Soenneker.Extensions.IFormFile" Version="11.0.839" />
<PackageReference Include="Soenneker.Extensions.IFormFile" />
paket add Soenneker.Extensions.IFormFile --version 11.0.839
#r "nuget: Soenneker.Extensions.IFormFile, 11.0.839"
#:package Soenneker.Extensions.IFormFile@11.0.839
#addin nuget:?package=Soenneker.Extensions.IFormFile&version=11.0.839
#tool nuget:?package=Soenneker.Extensions.IFormFile&version=11.0.839
Soenneker.Extensions.IFormFile
Copies an ASP.NET Core IFormFile into an independently owned MemoryStream positioned for reading.
Installation
dotnet add package Soenneker.Extensions.IFormFile
Buffer an upload
using Soenneker.Extensions.IFormFile;
const long maxUploadBytes = 10 * 1024 * 1024;
if (formFile.Length > maxUploadBytes)
return Results.BadRequest("The file is too large");
await using MemoryStream stream = await formFile.ToMemoryStream(cancellationToken);
await ProcessUpload(stream, cancellationToken);
Both overloads copy the entire file and reset the returned stream to position zero. They do not impose a size limit, validate the declared content type, scan the content, or sanitize IFormFile.FileName. Enforce those policies before buffering or persisting an untrusted upload.
The default overload pre-sizes a normal MemoryStream when the declared file length fits in an int:
await using MemoryStream stream = await formFile.ToMemoryStream(cancellationToken);
Use the utility overload when a scoped recyclable-stream utility is already available:
await using MemoryStream stream =
await formFile.ToMemoryStream(memoryStreamUtil, cancellationToken);
The utility-provided stream is cleared before copying, so bytes from an earlier use are not retained in the result.
The caller owns the returned stream and must dispose it. If copying fails or is cancelled, the extension disposes the stream before propagating the failure. The input file and utility must be non-null.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.Stream (>= 11.0.175)
- Soenneker.Utils.MemoryStream (>= 11.0.1606)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.839 | 29 | 10/27/2026 |
| 11.0.838 | 59 | 10/26/2026 |
| 11.0.837 | 61 | 10/26/2026 |
| 11.0.836 | 58 | 10/26/2026 |
| 11.0.834 | 55 | 10/26/2026 |
| 11.0.833 | 57 | 10/26/2026 |
| 11.0.832 | 60 | 10/26/2026 |
| 4.0.831 | 115 | 10/15/2026 |
| 4.0.830 | 88 | 10/15/2026 |
| 4.0.829 | 89 | 10/14/2026 |
| 4.0.828 | 76 | 10/14/2026 |
| 4.0.827 | 82 | 10/14/2026 |
| 4.0.826 | 88 | 10/14/2026 |
| 4.0.824 | 88 | 10/14/2026 |
| 4.0.817 | 92 | 10/13/2026 |
| 4.0.816 | 91 | 10/12/2026 |
| 4.0.814 | 84 | 10/12/2026 |
| 4.0.813 | 95 | 10/11/2026 |
| 4.0.811 | 102 | 10/11/2026 |
| 4.0.810 | 162 | 9/30/2026 |
Remove redundant framework conditions