BirdMessenger 3.1.4
dotnet add package BirdMessenger --version 3.1.4
NuGet\Install-Package BirdMessenger -Version 3.1.4
<PackageReference Include="BirdMessenger" Version="3.1.4" />
paket add BirdMessenger --version 3.1.4
#r "nuget: BirdMessenger, 3.1.4"
// Install BirdMessenger as a Cake Addin #addin nuget:?package=BirdMessenger&version=3.1.4 // Install BirdMessenger as a Cake Tool #tool nuget:?package=BirdMessenger&version=3.1.4
<div style="text-align: left"><img src="docs/img/logo.png" height="120px">
BirdMessenger
"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 3.1.4
.NET CLI
dotnet add package BirdMessenger --version 3.1.4
Getting Started
public static Uri TusEndpoint = new Uri("http://localhost:5094/files");
static async Task Main(string[] args)
{
await DemoUseTusClientByDependencyInjection();
await DemoUseHttpClient();
}
/// <summary>
/// recommend using DependencyInjection
/// </summary>
private static async Task DemoUseTusClientByDependencyInjection()
{
var services = new ServiceCollection();
services.AddHttpClient<ITusClient, TusClient>(); // configure httpClient ,refer to https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
var serviceProvider = services.BuildServiceProvider();
var tusClient = serviceProvider.GetService<ITusClient>();
var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// file to be uploaded
FileInfo fileInfo = new FileInfo(Path.Combine(location, @"TestFile/test.txt"));
using var fileStream = new FileStream(fileInfo.FullName,FileMode.Open,FileAccess.Read);
MetadataCollection metadata = new MetadataCollection();
metadata["filename"] = fileInfo.Name;
TusCreateRequestOption tusCreateRequestOption = new TusCreateRequestOption()
{
Endpoint = TusEndpoint,
Metadata = metadata,
UploadLength = fileStream.Length
};
var resp = await tusClient.TusCreateAsync(tusCreateRequestOption, CancellationToken.None);
TusPatchRequestOption tusPatchRequestOption = new TusPatchRequestOption
{
FileLocation = resp.FileLocation,
Stream = fileStream,
//UploadBufferSize = 2*1024*1024, // upload size ,default value is 1MB
//UploadType = UploadType.Chunk, // setting upload file with Stream or chunk ,default value is Stream
OnProgressAsync = x =>
{
var uploadedProgress = (int)Math.Floor(100 * (double)x.UploadedSize / x.TotalSize);
Console.WriteLine($"OnProgressAsync-TotalSize:{x.TotalSize}-UploadedSize:{x.UploadedSize}-uploadedProgress:{uploadedProgress}");
return Task.CompletedTask;
},
OnCompletedAsync = x =>
{
var reqOption = x.TusRequestOption as TusPatchRequestOption;
Console.WriteLine($"File:{reqOption.FileLocation} Completed ");
return Task.CompletedTask;
},
OnFailedAsync = x =>
{
Console.WriteLine($"error: {x.Exception.Message}");
if (x.OriginHttpRequestMessage is not null)
{
//log httpRequest
}
if (x.OriginResponseMessage is not null)
{
//log response
}
return Task.CompletedTask;
}
};
var tusPatchResp = await tusClient.TusPatchAsync(tusPatchRequestOption, CancellationToken.None);
}
/// <summary>
/// using httpclient directly
/// </summary>
private static async Task DemoUseHttpClient()
{
using var httpClient = new HttpClient();
var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// file to be uploaded
FileInfo fileInfo = new FileInfo(Path.Combine(location, @"TestFile/test.txt"));
var fileStream = new FileStream(fileInfo.FullName,FileMode.Open,FileAccess.Read);
MetadataCollection metadata = new MetadataCollection();
metadata["filename"] = fileInfo.Name;
TusCreateRequestOption tusCreateRequestOption = new TusCreateRequestOption()
{
Endpoint = TusEndpoint,
Metadata = metadata,
UploadLength = fileStream.Length
};
var resp = await httpClient.TusCreateAsync(tusCreateRequestOption, CancellationToken.None);
bool isInvokeOnProgressAsync = false;
bool isInvokeOnCompletedAsync = false;
long uploadedSize = 0;
TusPatchRequestOption tusPatchRequestOption = new TusPatchRequestOption
{
FileLocation = resp.FileLocation,
Stream = fileStream,
//UploadBufferSize = 2*1024*1024, // upload size ,default value is 1MB
//UploadType = UploadType.Chunk, // setting upload file with Stream or chunk ,default value is Stream
OnProgressAsync = x =>
{
isInvokeOnProgressAsync = true;
uploadedSize = x.UploadedSize;
var uploadedProgress = (int)Math.Floor(100 * (double)x.UploadedSize / x.TotalSize);
Console.WriteLine($"OnProgressAsync-TotalSize:{x.TotalSize}-UploadedSize:{x.UploadedSize}-uploadedProgress:{uploadedProgress}");
return Task.CompletedTask;
},
OnCompletedAsync = x =>
{
isInvokeOnCompletedAsync = true;
var reqOption = x.TusRequestOption as TusPatchRequestOption;
Console.WriteLine($"File:{reqOption.FileLocation} Completed ");
return Task.CompletedTask;
},
OnFailedAsync = x =>
{
Console.WriteLine($"error: {x.Exception.Message}");
if (x.OriginHttpRequestMessage is not null)
{
//log httpRequest
}
if (x.OriginResponseMessage is not null)
{
//log response
}
return Task.CompletedTask;
}
};
var tusPatchResp = await httpClient.TusPatchAsync(tusPatchRequestOption, CancellationToken.None);
}
- You can see more examples in unit tests
Document
Development
Development is done on the 'master' branch.
Support and Sponsorship
<a href="https://www.jetbrains.com" target="_blank"> <img src="./docs/img/jetbrains_logo.png" title="JetBrains" width="100" /> </a>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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 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 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on BirdMessenger:
Package | Downloads |
---|---|
Hopex.ApplicationServer.Extensions.Package
Hopex Application Server Packager |
|
TheFusionWorks.Platforms
These are base utility classes developed by The Fusion Works which other packages and applications are built off. |
|
Codehard.FileService.Client
A client library for Codehard's File Service. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.1.4 | 769 | 10/28/2024 | |
3.1.3 | 5,721 | 5/21/2024 | |
3.1.2 | 27,079 | 10/7/2023 | |
3.1.1 | 2,125 | 8/14/2023 | |
3.1.0 | 14,759 | 11/27/2022 | |
3.0.2 | 846 | 11/8/2022 | |
3.0.1 | 410 | 11/8/2022 | |
3.0.0 | 884 | 10/17/2022 | |
3.0.0-beta1 | 201 | 8/14/2022 | |
2.2.1 | 68,901 | 6/11/2022 | |
2.2.0 | 4,254 | 3/6/2022 | |
2.1.0-bata | 273 | 10/17/2021 | |
2.0.1 | 294,049 | 3/2/2021 | |
2.0.0 | 325,545 | 10/23/2020 | |
1.0.1 | 519 | 7/26/2020 | |
1.0.0 | 666 | 8/25/2019 | |
1.0.0-beta1 | 466 | 8/2/2019 | |
0.1.6 | 537 | 11/18/2019 | |
0.1.5 | 680 | 11/17/2019 | |
0.1.4 | 775 | 11/27/2018 | |
0.1.3 | 748 | 11/3/2018 | |
0.1.2 | 742 | 10/24/2018 | |
0.1.1 | 746 | 10/19/2018 | |
0.1.0 | 814 | 10/14/2018 |