HTTP Transfers
Getting Started
Section titled “Getting Started”| GitHub | |
| Downloads | |
| Blazor |
Shiny HTTP Transfers enables background uploads and downloads that continue even when your app is suspended. On iOS, transfers are managed by the OS via NSURLSession background sessions and resume after app restarts. On Android, Windows, Linux, macOS, and plain .NET hosts a managed HttpClient loop drives transfers and supports resumable downloads via HTTP Range requests (on Android the loop runs inside a foreground service). On Blazor WebAssembly, transfers are queued to IndexedDB and drained by a Service Worker via the Background Sync API.
Features
Section titled “Features”- Background uploads and downloads
- Multipart and raw upload support
- Progress tracking with speed and ETA
- Automatic resume after app restart
- Resumable downloads on Android, Windows, Linux, macOS, and plain .NET via HTTP Range requests
- Metered/unmetered network control
- Managed transfer list for UI binding
- Cross-platform: iOS, Android, Windows, Linux, macOS, Blazor WebAssembly
Platform Notes
Section titled “Platform Notes”| Platform | Package | Backing |
|---|---|---|
| iOS | Shiny.Net.Http | NSURLSession background session |
| Android | Shiny.Net.Http | Foreground service hosting a managed HttpClient + IConnectivity loop; resumable downloads via HTTP Range |
| Windows | Shiny.Net.Http | Managed HttpClient + IConnectivity loop; resumable downloads via HTTP Range |
| Linux / macOS / Plain .NET | Shiny.Net.Http | Managed HttpClient + IConnectivity loop; resumable downloads via HTTP Range |
| Blazor WebAssembly | Shiny.Net.Http.Blazor | Service Worker Background Sync + IndexedDB; downloads not resumable |
Background Delegate
Section titled “Background Delegate”Implement IHttpTransferDelegate to handle transfer completion and errors in the background.
public partial class MyTransferDelegate : IHttpTransferDelegate{ readonly ILogger<MyTransferDelegate> logger;
public MyTransferDelegate(ILogger<MyTransferDelegate> logger) { this.logger = logger; }
public Task OnCompleted(HttpTransferRequest request) { this.logger.LogInformation("Transfer completed: {Id}", request.Identifier); return Task.CompletedTask; }
public Task OnError(HttpTransferRequest request, int statusCode, Exception ex) { this.logger.LogError(ex, "Transfer failed: {Id}, Status: {Status}", request.Identifier, statusCode); return Task.CompletedTask; }}Android Foreground Service
Section titled “Android Foreground Service”On Android, background transfers run as a foreground service. Customize the notification:
#if ANDROIDpublic partial class MyTransferDelegate : IAndroidForegroundServiceDelegate{ public void Configure(AndroidX.Core.App.NotificationCompat.Builder builder) { builder .SetContentTitle("My App") .SetContentText("Transferring files...") .SetSmallIcon(Resource.Mipmap.appicon); }}#endifRegistration
Section titled “Registration”// iOS / Android / Windows (platform-aware: native sessions where available)services.AddHttpTransfers<MyTransferDelegate>();
// Linux / macOS / plain .NET (managed HttpClient loop)services.AddHttpClientTransfers<MyTransferDelegate>();
// Blazor WebAssemblyservices.AddBlazorHttpTransfers<MyTransferDelegate>(opts =>{ // Optional — defaults to the bundled Shiny service worker opts.ServiceWorkerPath = "./_content/Shiny.Net.Http.Blazor/http-transfer-sw.js";});On Blazor, ship the bundled SW at the configured path, or import its handlers from your own service worker:
importScripts('./_content/Shiny.Net.Http.Blazor/http-transfer-sw.js');AI Coding Assistant
Section titled “AI Coding Assistant”Step 1 — Add the marketplace:
claude plugin marketplace add shinyorg/skills Step 2 — Install the plugin:
claude plugin install shiny-client@shiny Step 1 — Add the marketplace:
copilot plugin marketplace add https://github.com/shinyorg/skills Step 2 — Install the plugin:
copilot plugin install shiny-client@shiny