BirajMainali.FluxFile
1.0.0
See the version list below for details.
dotnet add package BirajMainali.FluxFile --version 1.0.0
NuGet\Install-Package BirajMainali.FluxFile -Version 1.0.0
<PackageReference Include="BirajMainali.FluxFile" Version="1.0.0" />
paket add BirajMainali.FluxFile --version 1.0.0
#r "nuget: BirajMainali.FluxFile, 1.0.0"
// Install BirajMainali.FluxFile as a Cake Addin #addin nuget:?package=BirajMainali.FluxFile&version=1.0.0 // Install BirajMainali.FluxFile as a Cake Tool #tool nuget:?package=BirajMainali.FluxFile&version=1.0.0
FluxFile: Chunked File Upload Solution
FluxFile is a modular, customizable, and extensible file upload solution designed to efficiently handle large files by breaking them into manageable chunks. It allows integration with various storage systems, such as local file systems or cloud storage (e.g., Azure Blob Storage, AWS S3).
Table of Contents
Features
- Chunked Uploads: Efficiently uploads large files in smaller chunks to minimize memory and network overloads.
- Customizable Storage Providers: Easily switch between different storage backends.
- Pluggable Architecture: Core services and storage providers are interchangeable, providing flexibility for specific use cases.
Core Components
1. IFluxFileStorageProvider
This interface defines the contract for any file storage system used to save, retrieve, and manage file chunks.
public interface IFluxFileStorageProvider
{
Task<string> SaveChunkAsync(string fileName, byte[] chunk);
Task<byte[]> GetAllChunksAsync(string searchPattern);
Task DeleteChunkAsync(string fileName);
Task<string[]> GetAllChunkPathsAsync(string searchPattern);
}
2. IFluxFileUploadService
This service manages the high-level file upload process, working with the storage provider to handle chunk uploads, completion, and cancellation.
public interface IFluxFileUploadService
{
Task<string> StartUploadAsync(string fileName);
Task<string> UploadChunkAsync(string fileIdentifier, byte[] chunk, long chunkIndex);
Task CompleteUploadAsync(string fileIdentifier);
Task CancelUploadAsync(string fileIdentifier);
}
API Endpoints
1. Starting an Upload
Initialize the upload process and generate a unique identifier for the upload session.
app.MapPost("/upload/start", async ([FromForm] string fileName, IFluxFileUploadService uploadService) =>
{
var uniqueFileName = await uploadService.StartUploadAsync(fileName);
return Results.Ok(uniqueFileName);
}).DisableAntiforgery();
2. Uploading Chunks
Upload each chunk sequentially to the backend.
app.MapPost("/upload", async ([FromForm] string fileName, [FromForm] IFormFile file, [FromForm] long index,
IFluxFileUploadService uploadService) =>
{
var chunkFilePath = await uploadService.UploadChunkAsync(fileName, file.ToBytes(), index);
return Results.Ok(chunkFilePath);
}).DisableAntiforgery();
3. Completing the Upload
Finalize the upload by combining the chunks into the complete file.
app.MapPost("/upload/complete", async ([FromForm] string fileName, IFluxFileUploadService uploadService) =>
{
await uploadService.CompleteUploadAsync(fileName);
return Results.Ok();
}).DisableAntiforgery();
Customizing Storage Providers
Implement the IFluxFileStorageProvider
interface to integrate with any storage solution.
Example: Azure Blob Storage Provider
public class AzureBlobStorageProvider : IFluxFileStorageProvider
{
// Implementation details
}
Registering the Provider
Register the storage provider during application setup:
builder.Services.AddTransient<IFluxFileStorageProvider>(provider =>
{
// Configure the Azure provider
});
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.