Flowsy.Web.Streaming 1.0.0

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

// Install Flowsy.Web.Streaming as a Cake Tool
#tool nuget:?package=Flowsy.Web.Streaming&version=1.0.0                

Flowsy Web Streaming

This package includes some streaming services for web applications.

Configure Services

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddStreaming()
    .UseBuffering((options, serviceProvider) => 
    {
        // Set values according to your specific use case
        // options.MemoryThreshold = someNumber; 
        // options.BufferLimit = someNumber;
        // options.TempFileDirectory = "/path/to/some/directory";
        // options.TempFileDirectoryAccessor = () => "/path/to/some/directory";
        // options.BytePool = ArrayPool<byte>.Shared;    
    })
    .UseMultipartRequests((options, serviceProvider) =>
    {
        // Set values according to your specific use case
        // options.AllowedMimeTypes = new[] { "image/jpeg", "image/png" };
    })
    .UseChunkedFileUploads();

// Configure more services

var app = builder.Build();

// Configure request pipeline

app.Run();

Processing Requests

[ApiController]
[Route($"{Routes.Content}/[controller]")]
public class SomeController : ControllerBase
{
    private readonly IMultipartHandler _multipartHandler;

    public SomeController(IMultipartHandler multipartHandler)
    {
        _multipartHandler = multipartHandler;
    }
    
    [HttpPost]
    [DisableFormValueModelBinding]
    public async Task<IActionResult> UploadContentAsync(CancellationToken cancellationToken)
    {
        await using var multipartContent = await _multipartHandler.GetContentAsync(Request, cancellationToken);
        
        // The multipartContent.Data dictionary will contain the data fields from the request
        // The multipartContent.Files dictionary will contain the file fields from the request
        
        return Ok();
    }
}
[ApiController]
[Route($"{Routes.Content}/[controller]")]
public class AnotherController : ControllerBase
{
    private readonly IChunkedFileUploadHandler _chunkedFileUploadHandler;

    public AnotherController(IChunkedFileUploadHandler chunkedFileUploadHandler)
    {
        _chunkedFileUploadHandler = chunkedFileUploadHandler;
    }
    
    [HttpPost]
    public async Task<IActionResult> UploadChunkedFileAsync(ChunkedFileUploadRequest request, CancellationToken cancellationToken)
    {
        var correlationId = request.CorrelationId;
        
        // Example use case for ChunkedFileUploadRequest.Metadata
        if (request is {ChunkIndex: 0, Metadata: null})
            return BadRequest("Metadata is required for the first chunk.");
        
        var chunkDirectory = "/path/to/chunks/directory";
        var targetDirectory = "/path/to/final/directory";

        var status = status = await _chunkedFileUploadHandler.HandleAsync(request, chunkDirectory, targetDirectory, cancellationToken);
        
        // There are more chunks to upload, return 202 (accepted), so the client can upload the next chunk 
        if (status == ChunkedFileUploadRequestStatus.Partial)
            return Accepted();
        
        // All the chunks were uploaded
        // - The reassembled file was saved as /path/to/final/directory/{request.FileName}
        // - The metadata (if any) was saved as /path/to/final/directory/{request.FileName}.metadata
        
        // The file is fully uploaded, return 200 (ok)
        return Ok();
    }
}
Product Compatible and additional computed target framework versions.
.NET 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 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. 
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.0 93 12/4/2024
0.1.0 251 12/9/2023