MathieuDSTP / BirdMessenger

DotNET client implementation of the Tus protocol for resumable file uploads.

Home Page:https://tus.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BirdMessenger

NuGetNuGet

"Our aim is to solve the problem of unreliable file uploads once and for all. tus is a new open protocol for resumable uploads built on HTTP. It offers simple, cheap and reusable stacks for clients and servers. It supports any language, any platform and any network." - https://tus.io

BirdMessenger 中文名为:青鸟——相传为西王母的信使。 BirdMessnger 是一个基于.NET Standard 的 Tus协议的实现客户端。

Features

Protocol implementation

  • Create
  • HEAD
  • PATCH
  • OPTIONS
  • DELETE

Install

Package manager

Install-Package BirdMessenger -Version 2.2.1

.NET CLI

dotnet add package BirdMessenger --version 2.2.1

Getting Started

// file to be uploaded
FileInfo fileInfo = new FileInfo("test.txt");

// remote tus service
var hostUri = new Uri(@"http://localhost:5000/files");

// build a standalone tus client instance
var tusClient = TusBuild.DefaultTusClientBuild(hostUri)
                .Configure((options, httpClientBuilder) =>
                {
                    //customize http client
                    httpClientBuilder.ConfigureHttpClient(httpClient =>
                    {
                        httpClient.DefaultRequestHeaders.Authorization =
                            new AuthenticationHeaderValue("Bearer", "ACCESS_TOKEN");

                    });
                   /* httpClientBuilder.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler()
                    {
                        UseCookies = false,
                    });*/
                })
                .Build();

//hook up events
tusClient.UploadProgress += printUploadProcess;
tusClient.UploadFinish += uploadFinish;

 //define additional file metadata 
 MetadataCollection metadata = new MetadataCollection();
metadata["filename"] = fileInfo.FullName;
            
TusRequestOption requestOption = new TusRequestOption();
requestOption.HttpHeader["myHttpheader"] = "hello";
            
 //create upload url
 var fileUrl = await tusClient.Create(fileInfo,null,requestOption);

 var uploadOpt = new TusRequestOption()
 {
      UploadWithStreaming = true //enable streaming Upload
 };

 //upload file
 var uploadResult = await tusClient.Upload(fileUrl, fileInfo, null,uploadOpt);
  • You can see more examples in unit tests

Document

Wiki

Development

Development is done on the 'master' branch.

Who is using the library

Support and Sponsorship

About

DotNET client implementation of the Tus protocol for resumable file uploads.

https://tus.io/

License:MIT License


Languages

Language:C# 100.0%