BirajMainali.FluxFile 1.0.1

dotnet add package BirajMainali.FluxFile --version 1.0.1                
NuGet\Install-Package BirajMainali.FluxFile -Version 1.0.1                
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="BirajMainali.FluxFile" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BirajMainali.FluxFile --version 1.0.1                
#r "nuget: BirajMainali.FluxFile, 1.0.1"                
#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.
// Install BirajMainali.FluxFile as a Cake Addin
#addin nuget:?package=BirajMainali.FluxFile&version=1.0.1

// Install BirajMainali.FluxFile as a Cake Tool
#tool nuget:?package=BirajMainali.FluxFile&version=1.0.1                

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.

Configuration

builder.Services.AddFluxFile("local-fs-folder-or-null-or-empty-if-could-service");

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 fileName, byte[] chunk, long chunkIndex);
    Task CompleteUploadAsync(string fileName);
    Task CancelUploadAsync(string fileName);
}

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.1 79 10/15/2024
1.0.0 74 10/15/2024