TempFileStorage 4.0.0

dotnet add package TempFileStorage --version 4.0.0
                    
NuGet\Install-Package TempFileStorage -Version 4.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TempFileStorage" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TempFileStorage" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TempFileStorage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TempFileStorage --version 4.0.0
                    
#r "nuget: TempFileStorage, 4.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TempFileStorage@4.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TempFileStorage&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TempFileStorage&version=4.0.0
                    
Install as a Cake Tool

TempFileStorage

Easy .NET library for handling file asynchronous uploads and downloads.

Let the client upload a file via ´/upload-file´, send the file-key when you are submitting the form, and retrieve the file from ´ITempFileStorage´ in your controller. Or, generate a file in your backend, store the file in ´ITempFileStorage´ and send the key to the client. They can fetch it trough ´/download-file´.

Core package comes with In-Memory storage that is useful for testing. You can extend with SqlServer storage or Azure Blob storage.

Installing TempFileStorage

You should install TempFileStorage with NuGet:

Install-Package TempFileStorage

Or via the .NET Core command line interface:

dotnet add package TempFileStorage

Usage

Add temp files to your project:

builder.Services
    .AddTempFiles(options =>
    {
        // Temporary files will be held in memory, this should only be used for testing
        options.MemoryStorage();

        // The interval (in minutes) that will perform a cleanup of all temporary files (default is 15)
        options.CleanupInterval = 15;

        // The maximum file size (in bytes) that can be uploaded by the client (default is 50MB)
        options.MaxFileSize = 1024 * 1024 * 50;

        // The timeout (in minutes) for how long a file remains in the storage (default is 30)
        options.DefaultTimeout = 30;
    });

Register the Middleware in your Program.cs to activate the request-middleware:

// Map the download-middleware with a specific pattern (default is "/download-file")
app.MapTempFileDownload("/download-file");

// Map the upload-middleware with a specific pattern (default is "/upload-file")
app.MapTempFileUpload("/upload-file");

Azure.Storage.Blobs

You need to persist your temp file storage in storage blobs if you want to use this in production.

Install the package TempFileStorage.AzureBlobStorage with NuGet:

Swap the MemoryStorage with AzureBlobStorage

builder.Services
    .AddTempFiles(options =>
    {
        // Temporary files will be held Azure blob storage container (default is "temp-file-storage")
        options.AzureBlobStorage(builder.Configuration.GetConnectionString("StorageAccount"), containerName: "temp-file-storage");
    });

SqlServer

Or, when you're not working in Azure, you can opt for SqlServer storage.

Install the package TempFileStorage.SqlServer with NuGet:

Run the SQL-script install.sql on your DB-server.

Swap the MemoryStorage with SqlServer

builder.Services
    .AddTempFiles(options =>
    {
        // Temporary files will be held in database
        options.SqlServer(builder.Configuration.GetConnectionString("Database"));
    });
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on TempFileStorage:

Package Downloads
TempFileStorage.SqlServer

Package Description

TempFileStorage.AzureBlobStorage

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0 172 11/15/2025
4.0.0-alpha4 287 11/12/2025
3.2.0 501 11/7/2024
3.1.2 575 1/31/2024
3.1.1 2,403 1/9/2023
3.1.0 989 9/21/2022
3.0.0 2,087 6/17/2021
2.0.0 438 5/14/2021
1.0.0 834 11/15/2019