https://github.com/thsdmfwns/tussharp
Tus client for .net
https://github.com/thsdmfwns/tussharp
c-sharp client resumable-upload tus tus-protocol upload
Last synced: 2 months ago
JSON representation
Tus client for .net
- Host: GitHub
- URL: https://github.com/thsdmfwns/tussharp
- Owner: thsdmfwns
- License: mit
- Created: 2023-08-28T03:16:55.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-09-19T05:21:54.000Z (over 1 year ago)
- Last Synced: 2025-01-22T03:42:13.549Z (4 months ago)
- Topics: c-sharp, client, resumable-upload, tus, tus-protocol, upload
- Language: C#
- Homepage:
- Size: 246 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: MIT-LICENSE.txt
Awesome Lists containing this project
README
# Tus#
> **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](http://tus.io) and can be used inside **.net applications**.
**Protocol version:** 1.0.0
## Example
```c#
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{0, 3000, 5000, 10000, 20000},
MetaData = new Dictionary()
{
{"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](https://www.nuget.org/packages/System.IO.Pipelines/)
## License
This project is licensed under the MIT license.