ZNetCS.AspNetCore.ResumingFileResults
6.0.1
dotnet add package ZNetCS.AspNetCore.ResumingFileResults --version 6.0.1
NuGet\Install-Package ZNetCS.AspNetCore.ResumingFileResults -Version 6.0.1
<PackageReference Include="ZNetCS.AspNetCore.ResumingFileResults" Version="6.0.1" />
paket add ZNetCS.AspNetCore.ResumingFileResults --version 6.0.1
#r "nuget: ZNetCS.AspNetCore.ResumingFileResults, 6.0.1"
// Install ZNetCS.AspNetCore.ResumingFileResults as a Cake Addin #addin nuget:?package=ZNetCS.AspNetCore.ResumingFileResults&version=6.0.1 // Install ZNetCS.AspNetCore.ResumingFileResults as a Cake Tool #tool nuget:?package=ZNetCS.AspNetCore.ResumingFileResults&version=6.0.1
ZNetCS.AspNetCore.ResumingFileResults
A small package to allow using resume during transfering data over MVC application in ASP.NET Core.
It allows provide ETag
header as well as Last-Modified
one. It also supports following precondition headers: If-Match
, If-None-Match
, If-Modified-Since
, If-Unmodified-Since
, If-Range
.
ASP.NET Core 2.0
As from version 2.0 resuming is supported out of box inside ASP.NET Core. So all code related to resuming was removed. I left only part for Content-Disposition
inline.
Now all code relies on base .NET classes. Also support for multipart request is removed. To support that I would have to copy a lot of original code, because currently
there is no way to simple override some part of base classes.
Installing
Install using the ZNetCS.AspNetCore.ResumingFileResults NuGet package
PM> Install-Package ZNetCS.AspNetCore.ResumingFileResults
Usage
When you install the package, it should be added to your .csproj
. Alternatively, you can add it directly by adding:
<ItemGroup>
<PackageReference Include="ZNetCS.AspNetCore.ResumingFileResults" Version="6.0.1" />
</ItemGroup>
.NET 6
// Add services to the container.
builder.Services.AddResumingFileResult();
.NET 5 and Below
In order to use the ResumingFileResults, you must configure the services in the ConfigureServices
call of Startup
:
public void ConfigureServices(IServiceCollection services)
{
services.AddResumingFileResult();
}
Use inside controller
Then in your controller you can use it in similar way as build in FileResult
helpers.
using ZNetCS.AspNetCore.ResumingFileResults.Extensions;
...
public IActionResult FileContents()
{
string webRoot = this.hostingEnvironment.WebRootPath;
var contents = System.IO.File.ReadAllBytes(Path.Combine(webRoot, "TestFile.txt"));
return this.ResumingFile(contents, "text/plain", "TestFile.txt");
}
...
public IActionResult FileStream()
{
string webRoot = this.hostingEnvironment.WebRootPath;
FileStream stream = System.IO.File.OpenRead(Path.Combine(webRoot, "TestFile.txt"));
return this.ResumingFile(stream, "text/plain", "TestFile.txt");
}
...
public IActionResult PhysicalFile()
{
string webRoot = this.hostingEnvironment.WebRootPath;
return this.ResumingPhysicalFile(Path.Combine(webRoot, "TestFile.txt"), "text/plain", "TestFile.txt");
}
...
public IActionResult VirtualFile()
{
return this.ResumingFile("TestFile.txt", "text/plain", "TestFile.txt");
}
Above examples will serve your data as Content-Disposition: attachment
. When fileName is not provided then data is served as Content-Disposition: inline
. Additionaly
it is possible provide ETag
and LastModified
headers.
public IActionResult File()
{
return new ResumingVirtualFileResult("TestFile.txt", "text/plain", "\"MyEtagHeader\"")
{
FileDownloadName = "TestFile.txt",
LastModified = DateTimeOffset.Now
};
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
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 |
---|---|---|
6.0.1 | 6,359 | 2/3/2022 |
2.2.0 | 4,631 | 10/11/2019 |
2.1.2 | 2,975 | 8/8/2018 |
2.1.1 | 1,115 | 6/20/2018 |
2.1.0-preview2-30045 | 814 | 2/7/2018 |
2.0.0 | 1,158 | 8/30/2017 |
1.0.7 | 1,261 | 5/19/2017 |
1.0.6 | 1,225 | 11/23/2016 |
1.0.5 | 1,360 | 9/28/2016 |
1.0.3 | 1,225 | 9/13/2016 |
1.0.2 | 1,217 | 9/12/2016 |
1.0.1 | 1,528 | 9/11/2016 |
Breaking Change: Drop support for netstandard and .net framework. Code refactoring. Dependency update. Library is now strong name signed.