shinyorg/shiny/shiny-http-transfers

Claude Code and agent skill by shinyorg/shiny

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Guide for generating code that uses Shiny.NET HTTP Transfers for background uploads and downloads on iOS/Android, Windows, Linux, macOS, and Blazor WASM (Service Worker Background Sync), including transfer progress surfaces - iOS Live Activities and the Android foreground-service notification

Install

npx vskill@latest install shinyorg/shiny/shiny-http-transfers

SKILL.md

The same SKILL.md was published earlier as shinyorg/shiny/shiny-http-transfers.

Shiny HTTP Transfers

Background HTTP upload and download management. On iOS, backed by native NSURLSession background sessions. On Android, Windows, Linux, macOS, and base .NET, backed by an in-process managed loop using HttpClient + IConnectivity that wakes on connectivity changes and supports resumable downloads via HTTP Range requests (uploads always restart); on Android this loop runs inside a foreground service. On Blazor WASM, backed by the Service Worker Background Sync API (IndexedDB queue drained by the SW via fetch() while the tab is closed).

When to Use This Skill

Use this skill when the user needs to:

  • Upload or download files in the background on iOS/Android
  • Monitor progress of HTTP file transfers
  • Queue background transfers that survive app suspension
  • Handle transfer errors with automatic retry logic
  • Upload files to Azure Blob Storage
  • Upload files to AWS S3
  • Build a UI that tracks active transfers with progress reporting
  • Perform multipart or raw file uploads
  • Download files with progress tracking and estimated time remaining

Library Overview

ItemValue
NuGetShiny.Net.Http (one package everywhere - its net11.0 build includes Blazor WASM)
NamespaceShiny.Net.Http
PlatformsiOS, tvOS (native NSURLSession); Android, Windows, Linux, macOS, .NET base (managed HttpClient loop); Blazor WASM (Service Worker)
DI Setupservices.AddHttpTransfers<TDelegate>() (iOS/tvOS/Android/Windows), services.AddHttpClientTransfers<TDelegate>() (Linux/macOS/plain .NET), or services.AddBlazorHttpTransfers<TDelegate>() (Blazor)

The registration extension methods live in the Shiny namespace and are available on IServiceCollection.

tvOS uses services.AddHttpTransfers<TDelegate>() and the same background NSUrlSession as iOS, so transfers continue while the app is suspended. Storage is the difference worth calling out: an Apple TV has no user-visible file system and a small, evictable app container — write transfer output to the cache directory and treat a completed download as something the OS may reclaim between launches.

Setup

1. Register Services

In your MauiProgram.cs:

csharp
using Shiny;
builder.Services.AddHttpTransfers<MyHttpTransferDelegate>();
2. Implement the Delegate

Create a class that implements IHttpTransferDelegate (or inherits from the abstract HttpTransferDelegate base class for built-in retry logic):

csharp
using Shiny.Net.Http;
public class MyHttpTransferDelegate : HttpTransferDelegate
{
public MyHttpTransferDelegate(
ILogger<MyHttpTransferDelegate> logger,
IHttpTransferManager manager
) : base(logger, manager, maxErrorRetries: 3) { }
public override Task OnCompleted(HttpTransferRequest request)
{
// Handle successful transfer completion
return Task.CompletedTask;
}
// Optional: override for 401 handling
protected override Task<HttpTransferRequest?> OnAuthorizationFailed(
HttpTransferRequest request, int retries)
{
// Return a new request with refreshed auth headers, or null to cancel
return Task.FromResult<HttpTransferRequest?>(null);
}
}

On Android, the delegate must also implement IAndroidForegroundServiceDelegate:

csharp
#if ANDROID
public partial class MyHttpTransferDelegate : IAndroidForegroundServiceDelegate
{
public void Configure(AndroidX.Core.App.NotificationCompat.Builder builder)
{
builder
.SetContentTitle("File Transfer")
.SetContentText("Transferring files in the background");
}
}
#endif
Linux / macOS / Plain .NET Setup

On non-platform .NET hosts (Linux, macOS server, console apps, etc.) call AddHttpClientTransfers<TDelegate>() instead of AddHttpTransfers<TDelegate>(). It registers HttpClientHttpTransferManager backed by an HttpClient loop driven by IConnectivity that wakes immediately on connectivity changes. Downloads resume after network interruption via HTTP Range requests (Range: bytes=N-, FileMode.Append when the server responds with 206 Partial Content); uploads always restart from scratch. Only a partial file the transfer itself wrote is resumed - a file already at LocalFilePath before the download was queued is overwritten - and a 416 for an already-complete partial file completes the transfer. The resume also checks the server file hasn't changed: the response that starts a download has its strong ETag (weak W/ tags are ignored) or, failing that, its Last-Modified stored internally beside the transfer, and the resume sends it as If-Range. A 206 appends; a 200 means the file changed, so the partial is truncated and the download restarts from byte 0 with the new validator. With neither header the resume is a plain Range request. The validator is removed with the transfer (completed, failed, cancelled). Apple (NSURLSession) does its own resume validation; Blazor has no resume. For safe resumes, servers should send a strong ETag - no app code is needed. A connection failure (no HTTP status) pauses a transfer as PausedByNoNetwork for the next pass instead of failing it.

TransferProgress.IsDeterministic is false for an unknown, zero or negative (iOS "unknown size") total; PercentComplete is then -1 and EstimatedTimeRemaining is zero.

The managed loop resolves its HttpClient from IHttpClientFactory using the named client HttpClientHttpTransferProcess.HttpClientName ("Shiny.Net.Http"). To customize it (timeouts, default headers, a custom primary handler, Polly, etc.), configure that named client after registering transfers: services.AddHttpClient("Shiny.Net.Http").ConfigureHttpClient(c => c.Timeout = TimeSpan.FromMinutes(10));. (iOS/Mac Catalyst use NSUrlSession and ignore this.)

IConnectivity is registered for you (AddConnectivity() from Shiny.Core - register your own first to replace it). A default JSON filesystem repository is registered automatically and persists transfer state to {LocalApplicationData}/Shiny across process restarts.

Cancelled downloads clean up any partial file on disk so a subsequent re-queue starts fresh.

Blazor WASM Setup (Shiny.Net.Http)
csharp
using Shiny;
builder.Services.AddBlazorHttpTransfers<MyDelegate>(opts =>
{
opts.ServiceWorkerPath = "./_content/Shiny.Net.Http/http-transfer-sw.js";
});

AddBlazorHttpTransfers ships in Shiny.Net.Http's net11.0 build - never reference Shiny.Net.Http.Blazor, which was merged into Shiny.Net.Http in v6. It uses the Service Worker Background Sync API. Queued transfers are written to IndexedDB; the Service Worker's sync event handler drains the queue via fetch() and stores download bodies as Blobs back into IndexedDB. When the tab reopens, the C# BrowserHttpTransferManager reconciles results from IndexedDB and fires the IHttpTransferDelegate callbacks.

Ship the bundled SW file or import its handlers from your own service worker:

js
// my-sw.js
importScripts('./_content/Shiny.Net.Http/http-transfer-sw.js');

Blazor limitations (v1):

  • No resumable downloads — the SW receives a whole response Blob; partial-body appending is not supported.
  • Retries — the SW retries a transfer that failed with no status (network), 408, 429 or 5xx up to 5 times (it goes back to pending, no OnError); other statuses, or exhausted retries, mark it error and fire OnError once. Drains are serialised, so a transfer is sent once even when the sync event and the page's drain message arrive together, and a transfer the worker was stopped in the middle of is picked up again.
  • Pause/Resume is best-effort — Pause(identifier) marks the IndexedDB entry paused so the SW drain skips it (it only processes pending), and Resume(identifier) re-queues it. An already in-flight SW fetch() cannot be aborted (no AbortController wiring), so it runs to completion; and because downloads aren't resumable, a resumed download restarts from zero. Pausing a not-yet-started (or retry-pending) transfer works cleanly.
  • Upload bodies are base64-bridged through JS interop and persisted as IndexedDB Blobs. Fine for small/medium files; very large uploads should wait for a future OPFS streaming path.
  • Browser support for Background Sync is Chromium-only (no Firefox, no Safari). On unsupported browsers queued transfers drain while the tab is foreground and then sit in IndexedDB until next visit.
  • Retrieving completed downloads: use (manager as Shiny.Net.Http.BrowserHttpTransferManager).GetDownloadBytes(identifier) which reads the blob back out of IndexedDB as a byte[].

Do not confuse with `Shiny.Jobs` on Blazor — Jobs only run while the tab is open because the WASM runtime cannot execute inside a Service Worker. HTTP transfers are the one exception because fetch() is pure JS that the SW can run on its own.

Code Generation Instructions

When generating code that uses Shiny HTTP Transfers, follow these conventions:

Queuing Transfers
  • Always use IHttpTransferManager via dependency injection; never instantiate directly.
  • HttpTransferRequest requires 4 positional parameters: Identifier, Uri, TransferType, LocalFilePath:

``csharp var request = new HttpTransferRequest( "my-download", "https://example.com/file.zip", TransferType.Download, Path.Combine(FileSystem.AppDataDirectory, "file.zip") ); await transferManager.Queue(request); ``

  • Use a unique Identifier for each HttpTransferRequest so individual transfers can be tracked and cancelled.
  • For uploads, ensure the LocalFilePath points to an existing file before queuing.
  • Set UseMeteredConnection = false to restrict large transfers to Wi-Fi only.
  • Choose the correct TransferType: UploadMultipart for form-based uploads, UploadRaw for streaming the file body directly, Download for downloads.
Monitoring Progress
  • Subscribe to the UpdateReceived C# event on IHttpTransferManager for a global stream of all transfer updates (event EventHandler<HttpTransferResult>). Rx has been removed from Shiny.Net.Http; remember to -= your handler when done.
  • Subscribe to the CountChanged event (event EventHandler<int>) to react to the number of active transfers.
  • Use the WatchTransfer(identifier) extension method to await a single transfer to completion — it returns Task<HttpTransferResult> and unsubscribes from UpdateReceived internally.
  • For UI binding, use HttpTransferMonitor -- call Start() to begin monitoring and bind to the Transfers collection of HttpTransferObject items. These implement INotifyPropertyChanged.
Pausing & Resuming

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1,583
Repository forks
248
7-day trend score
37

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/shinyorg/shiny/shiny-http-transfers/badge)](https://verified-skill.com/skills/shinyorg/shiny/shiny-http-transfers)

Something wrong with this skill or its page? Tell us.