npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spoonconsulting/capacitor-background-uploader

v0.2.2

Published

Capacitor plugin: reliable background uploads to S3, Azure Blob and generic endpoints on iOS (URLSession background) and Android (WorkManager + OkHttp).

Readme

capacitor-background-uploader

Capacitor 8 plugin for background file uploads to S3, Azure Blob and generic HTTP endpoints.

  • iOS: URLSession background session. Transfers run in the system daemon, survive suspension, and relaunch the app on completion. Files are streamed from disk (uploadTask(fromFile:)), never loaded into memory.
  • Android: WorkManager (scheduling, constraints, persistence) + OkHttp (streamed body, progress). Runs as a foreground data-sync worker with a notification.

Install

npm install @spoonconsulting/capacitor-background-uploader   # or publish and install from npm
npx cap sync

iOS: AppDelegate hook (required)

import CapacitorBackgroundUploader // module name of the Swift package

func application(_ application: UIApplication,
                 handleEventsForBackgroundURLSession identifier: String,
                 completionHandler: @escaping () -> Void) {
    BackgroundUploaderPlugin.handleEventsForBackgroundURLSession(identifier: identifier,
                                                                 completionHandler: completionHandler)
}

Android

Nothing extra. The manifest permissions are merged automatically. Android 13+ shows the notification only after the user grants notifications.

Usage

import { BackgroundUploader } from 'capacitor-background-uploader';

// S3 presigned PUT
await BackgroundUploader.enqueue({
  uploads: [{
    id: 'photo-123',
    filePath: nativeFilePath,            // absolute path or file:// URL
    url: presignedPutUrl,
    mode: 'put',
    provider: 's3',
    headers: { 'Content-Type': 'image/jpeg' }, // must match what was signed
  }],
});

// Azure SAS (adds x-ms-blob-type: BlockBlob automatically)
await BackgroundUploader.enqueue({
  uploads: [{ id: 'doc-9', filePath, url: sasUrl, provider: 'azure' }],
});

// S3 POST policy or generic multipart form
await BackgroundUploader.enqueue({
  uploads: [{
    id: 'media-7', filePath, url: postUrl, mode: 'multipart',
    fields: { key: 'uploads/7.jpg', policy: '...', 'x-amz-signature': '...' },
    fileField: 'file',
  }],
});

// Events
await BackgroundUploader.addListener('uploadProgress', (e) => { /* e.progress 0-100 */ });
await BackgroundUploader.addListener('uploadCompleted', (e) => { /* e.statusCode, e.response */ });
await BackgroundUploader.addListener('uploadFailed', (e) => { /* e.error, e.permanent */ });

// On app start: handle results that finished while the WebView was not listening.
const { results } = await BackgroundUploader.getPendingResults();
// ...handle each result (dedupe by id against events you already handled)...
await BackgroundUploader.acknowledge({ ids: results.map((r) => (r.completed ?? r.failed)!.id) });

Behavior

  • Retries: transient failures (network, timeout, HTTP 408/429/5xx) are retried with backoff up to maxAttempts (default 4). HTTP 4xx fails permanently.
  • Restart from zero: each attempt re-sends the whole file. Resume is not supported (see limits).
  • Progress: emitted at most every 500 ms per upload, plus 100%.
  • Persistence: iOS keeps upload records and pending results in UserDefaults. Android keeps state in WorkManager's database. Both survive app kills.
  • Concurrency: iOS uses httpMaximumConnectionsPerHost = 2. Android uses a semaphore of 2.
  • Web: no background transfer. Methods reject or return empty.

Known limits and open items

  • No resumable uploads yet. Large files on unstable networks restart from zero on each retry. The next step is S3 multipart (presigned part URLs) and Azure Block Blob staging, which lets each part retry on its own.
  • Re-enqueue with an active id: Android replaces the running upload; iOS rejects it. Make both match before release.
  • iOS progress map: progressFor reads a dictionary written on the URLSession delegate queue. Guard it with a lock.
  • Not compiled here: the Swift files parse, but they have not been type-checked or built against Capacitor. The Java has not been compiled (no Android SDK on the build machine).
  • Placeholders: com.example.backgrounduploader, the podspec homepage/author, and the Capacitor SPM version must be set to your values and verified against Capacitor 8 docs.
  • Verify before release: the WorkManager execution time limit for foreground workers, ForegroundInfo with a service type on your targets, and the Capacitor Swift package URL.