TusSharp 1.0.0

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

// Install TusSharp as a Cake Tool
#tool nuget:?package=TusSharp&version=1.0.0                

Tus#

<img alt="Tus logo" src="https://github.com/tus/tus.io/blob/main/public/images/tus1.png?raw=true" width="30%" align="right" />

tus is a protocol based on HTTP for resumable file uploads. Resumable means that an upload can be interrupted at any moment and can be resumed without re-uploading the previous data again. An interruption may happen willingly, if the user wants to pause, or by accident in case of an network issue or server outage.

Tus# is a simple and fast .net client for the tus resumable upload protocol and can be used inside .net applications.

Protocol version: 1.0.0

Example

using TusSharp;

var client = new TusClient();
//Create file stream
const string filePath = "/path/to/test.mp4";
using var stream = File.OpenRead(filePath);
var fileInfo = new FileInfo(filePath);
//Create new option
var opt = new TusUploadOption()
{
    EndPoint = new Uri("http://localhost:1080/files"),
    ChunkSize = 1 * 1024 * 1024, //1MB
    RetryDelays = new List<int>{0, 3000, 5000, 10000, 20000},
    MetaData = new Dictionary<string, string>()
    {
        {"filename", fileInfo.Name}
    },
    OnCompleted = () =>
    {
        Console.WriteLine("completed upload \n");
    },
    OnFailed = (originalResponseMsg, originalRequestMsg, errMsg, exception) =>
    {
        Console.WriteLine("upload failed beacuse : {errMsg} \n");
    },
    OnProgress = (chunkSize, uploadedSize, totalSize) =>
    {
        var progressPercentage = (double)uploadedSize / totalSize * 100;
        Console.WriteLine($"upload | chunkSize : {chunkSize} | uploadedSize : {uploadedSize} | total : {totalSize} |  {progressPercentage:F2}\n");
    }
};

//Create upload with option and FileStream
using var upload = client.Upload(opt, stream);

//start the upload
await upload.Start();   

Dependency

System.IO.Pipelines

License

This project is licensed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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 1,226 11/2/2023