{"id":21991598,"url":"https://github.com/thsdmfwns/tus-blazor-client","last_synced_at":"2025-10-07T09:47:59.531Z","repository":{"id":195710523,"uuid":"693495080","full_name":"thsdmfwns/tus-blazor-client","owner":"thsdmfwns","description":"tus-js-client wrapper for .net blazor","archived":false,"fork":false,"pushed_at":"2023-10-24T05:37:20.000Z","size":260,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T16:46:31.038Z","etag":null,"topics":["blazor-webassembly","resumable-upload","tus","tus-protocol","upload"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thsdmfwns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-19T06:28:10.000Z","updated_at":"2025-03-13T19:06:52.000Z","dependencies_parsed_at":"2023-09-22T16:56:36.803Z","dependency_job_id":"978bcd7b-d600-4396-ae54-ffeae03104ff","html_url":"https://github.com/thsdmfwns/tus-blazor-client","commit_stats":null,"previous_names":["thsdmfwns/tus-blazor-client"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thsdmfwns%2Ftus-blazor-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thsdmfwns%2Ftus-blazor-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thsdmfwns%2Ftus-blazor-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thsdmfwns%2Ftus-blazor-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thsdmfwns","download_url":"https://codeload.github.com/thsdmfwns/tus-blazor-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251715112,"owners_count":21631839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor-webassembly","resumable-upload","tus","tus-protocol","upload"],"created_at":"2024-11-29T20:10:12.560Z","updated_at":"2025-10-07T09:47:54.496Z","avatar_url":"https://github.com/thsdmfwns.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tus-blazor-client\n\u003cimg alt=\"Tus logo\" src=\"https://github.com/tus/tus.io/blob/main/public/images/tus1.png?raw=true\" width=\"30%\" align=\"right\" /\u003e\n\n\u003e **tus** is a protocol based on HTTP for _resumable file uploads_. Resumable\n\u003e means that an upload can be interrupted at any moment and can be resumed without\n\u003e re-uploading the previous data again. An interruption may happen willingly, if\n\u003e the user wants to pause, or by accident in case of an network issue or server\n\u003e outage.\n\ntus-blazor-client is a wrapper library project for [tus-js-client](https://github.com/tus/tus-js-client) that can be used in .NET Blazor.\n\n\n## Why do I use this?\nThe file I/O speed in .NET Blazor is not suitable for sending large files, and there are also limitations on the size of files that can be transferred. Therefore, sending large files with pure C# code in Blazor can be a challenging task.\n\n## Installation\n\n### Install tus-js-client\n\n- Unminified version: [tus.js](https://cdn.jsdelivr.net/npm/tus-js-client@latest/dist/tus.js)\n- Minified version: [tus.min.js](https://cdn.jsdelivr.net/npm/tus-js-client@latest/dist/tus.min.js) (recommended)\n\n```html\n\u003c!-- project/wwwroot/index.html --\u003e\n...\n    \u003cdiv id=\"blazor-error-ui\"\u003e\n        An unhandled error has occurred.\n        \u003ca href=\"\" class=\"reload\"\u003eReload\u003c/a\u003e\n        \u003ca class=\"dismiss\"\u003e🗙\u003c/a\u003e\n    \u003c/div\u003e\n    \u003cscript src=\"_framework/blazor.webassembly.js\"\u003e\u003c/script\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/tus-js-client@latest/dist/tus.min.js\"\u003e\u003c/script\u003e\n```\n\n\n\n### Install tus-blazor-client\nuse [Nuget](https://www.nuget.org/packages/TusBlazorClient/) ```dotnet add package TusBlazorClient --version 1.0.1```\n\n### Add TusBlazorClient in ServiceProvider\n```csharp\n// project/Program.cs\n...\nbuilder.Services.AddTusBlazorClient();\nawait builder.Build().RunAsync();\n```\n\n## Example\n````csharp\n@inject TusClient TusClient\n\n\u003cinput type=\"file\" @ref=\"_fileElement\"/\u003e\n\u003cbutton onclick=\"@Upload\"\u003eupload\u003c/button\u003e\n\n@code {\n    private ElementReference _fileElement;\n    private TusUpload? _tusUpload;\n    \n    private async Task Upload()\n    {\n        // Get the selected file from the input element\n        var file =  (await TusClient.GetFileInputElement(_fileElement).GetFiles()).First();\n        // Get the selected file's info\n        var fileInfo = await file.GetFileInfo();\n        // Create a new tus upload\n        var opt = new TusOptions\n        {\n            Endpoint = new Uri(\"http://localhost:1080/files\"),\n            Metadata = new Dictionary\u003cstring, string\u003e()\n            {\n                {\"filename\", fileInfo.Name},\n            },\n            OnError = (err) =\u003e\n            {\n                Console.WriteLine($\"Failed because: {err.ErrorMessage}\");\n            },\n            OnProgress = (bytesUploaded, bytesTotal) =\u003e\n            {\n                var percentage = (double)bytesUploaded / bytesTotal;\n                Console.WriteLine($\"{bytesUploaded} {bytesTotal} {percentage:F}%\");\n            },\n            OnSuccess = async () =\u003e\n            {\n                var url = await _tusUpload.GetUrl();\n                Console.WriteLine($\"Download {fileInfo.Name} from {url}\");\n            },\n        };\n        _tusUpload = await TusClient.Upload(file, opt);\n        \n        // Check if there are any previous uploads to continue.\n        var previousUploads = await _tusUpload.FindPreviousUpload();\n        if (previousUploads.Count \u003e 0)\n        {\n            // Found previous uploads so we select the first one.\n            await _tusUpload.ResumeFromPreviousUpload(previousUploads.First());\n        }\n        \n        // Start the upload\n        await _tusUpload.Start();\n    }\n}\n````\n\n### API\nCheck [Wiki](https://github.com/thsdmfwns/tus-blazor-client/wiki)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthsdmfwns%2Ftus-blazor-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthsdmfwns%2Ftus-blazor-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthsdmfwns%2Ftus-blazor-client/lists"}