CommonNetFuncs.Compression
3.4.2
dotnet add package CommonNetFuncs.Compression --version 3.4.2
NuGet\Install-Package CommonNetFuncs.Compression -Version 3.4.2
<PackageReference Include="CommonNetFuncs.Compression" Version="3.4.2" />
<PackageVersion Include="CommonNetFuncs.Compression" Version="3.4.2" />
<PackageReference Include="CommonNetFuncs.Compression" />
paket add CommonNetFuncs.Compression --version 3.4.2
#r "nuget: CommonNetFuncs.Compression, 3.4.2"
#addin nuget:?package=CommonNetFuncs.Compression&version=3.4.2
#tool nuget:?package=CommonNetFuncs.Compression&version=3.4.2
CommonNetFuncs.Compression
This project contains helper methods for compressing files into a zip file as well as compress and decompress streams.
Contents
Files
Used for compressing file data into a ZipArchive class.
<details> <summary><h3>Usage Examples</h3></summary>
Add file to zip folder and write it to disk.
using static CommonNetFuncs.Compression.Files;
using static CommonNetFuncs.Excel.Npoi.Export;
public async Task CreatePeopleZipFile()
{
List<Person> people = [];
//Some code populating people list here
await using MemoryStream zipStream = new();
//Converts list to excel file in a MemoryStream (see Excel.Npoi)
await using MemoryStream peopleExcelStream = await people.GenericExcelExport() ?? new();
await (peopleExcelStream, "People.xlsx").ZipFile(zipStream, CompressionLevel.SmallestSize);
peopleExcelStream.Dispose();
zipStream.Position = 0;
//Write the zip file to disk
await using FileStream fs = new("People.zip", FileMode.Create, FileAccess.Write);
await zipStream.CopyToAsync(fs);
fs.Flush();
}
Add multiple files to a ZipArchive object and write it to disk.
public async Task CreatePeopleAndAddressesZipFile()
{
List<Person> people = [];
List<Address> addresses = [];
//Some code populating people and addresses lists here
await using MemoryStream zipStream = new();
using ZipArchive archive = new(zipStream, ZipArchiveMode.Create, true);
//Convert lists to excel file in a MemoryStream (see Excel.Npoi) then add them to a ZipArchive
await using MemoryStream peopleExcelStream = await people.GenericExcelExport() ?? new();
await peopleExcelStream.AddFileToZip(archive, "People.xlsx", CompressionLevel.SmallestSize);
peopleExcelStream.Dispose();
await using MemoryStream addressesExcelStream = await addresses.GenericExcelExport() ?? new();
await addressesExcelStream.AddFileToZip(archive, "Addresses.xlsx", CompressionLevel.SmallestSize);
addressesExcelStream.Dispose();
archive.Dispose();
await using FileStream fs = new("PeopleAndAddresses.zip", FileMode.Create, FileAccess.Write);
await zipStream.CopyToAsync(fs);
fs.Flush();
}
</details>
Streams
Used for compressing and decompressing streams of data. Currently supported compression algorithms:
- Brotli
- GZip
- Deflate
- ZLib
<details> <summary><h3>Usage Examples</h3></summary>
Compress and then decompress a stream. CommonNetFuncs.Web.Requests has a more practical implementation decompressing compressed API responses.
public async Task CompressAndDecompressFile()
{
//Create stream
await using FileStream fileStream = new("TestFile.txt", FileMode.Open, FileAccess.Read);
//Compress the stream
await using MemoryStream compressedStream = new();
await fileStream.DecompressStream(compressedStream, ECompressionType.Gzip);
//Decompress the stream
await using MemoryStream decompressedStream = new();
await compressedStream.DecompressStream(decompressedStream, ECompressionType.Gzip);
}
</details>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net9.0
- CommonNetFuncs.Core (>= 3.4.2)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on CommonNetFuncs.Compression:
Package | Downloads |
---|---|
CommonNetFuncs.Web.Aws.S3
Helper methods that deal with AWS S3 interactions |
|
CommonNetFuncs.Web.Requests
Helper methods that deal with creating, sending, and handling the responses from REST API calls |
|
CommonNetFuncs.Web.Common
Helper methods that deal with general web applications. |
|
CommonNetFuncs.Email
Helper methods that deal with sending email, including an SMTP email sending service and an HTML email builder helper. |
|
CommonNetFuncs.Web.Middleware
Misc middlewares for ASP.NET MVC applications |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.4.2 | 26 | a day ago |
3.4.1 | 58 | 4 days ago |
3.4.0 | 61 | 4 days ago |
3.3.14 | 169 | 13 days ago |
3.3.11 | 159 | 15 days ago |
3.3.10 | 249 | 21 days ago |
3.3.9 | 221 | 21 days ago |
3.3.7 | 209 | 22 days ago |
3.3.0 | 189 | a month ago |
3.2.13 | 282 | 4 months ago |
3.2.9 | 122 | 4 months ago |
3.2.6 | 96 | 4 months ago |
3.2.0 | 144 | 5 months ago |
3.1.0 | 164 | 6 months ago |
3.0.0 | 118 | 6 months ago |
2.1.3 | 119 | 6 months ago |
2.1.0 | 113 | 6 months ago |
2.0.5 | 112 | 6 months ago |
2.0.2 | 117 | 7 months ago |
2.0.1 | 113 | 7 months ago |
2.0.0 | 109 | 7 months ago |
1.0.47 | 125 | 7 months ago |
1.0.42 | 148 | 7 months ago |
1.0.40 | 141 | 7 months ago |
1.0.37 | 124 | 7 months ago |
1.0.31 | 130 | 7 months ago |
1.0.28 | 127 | 7 months ago |
1.0.26 | 182 | 8 months ago |
1.0.25 | 110 | 8 months ago |
1.0.24 | 105 | 8 months ago |
1.0.18 | 145 | 8 months ago |
1.0.17 | 168 | 8 months ago |
1.0.16 | 143 | 8 months ago |
1.0.14 | 124 | 8 months ago |
1.0.13 | 138 | 9 months ago |
1.0.12 | 127 | 9 months ago |
1.0.11 | 124 | 9 months ago |
1.0.10 | 150 | 9 months ago |
1.0.9 | 137 | 9 months ago |
1.0.8 | 164 | 9 months ago |
1.0.7 | 145 | 9 months ago |
1.0.1 | 165 | 9 months ago |
1.0.0 | 140 | 9 months ago |