Skip to main content

B2 Transfer

@sntxrr/b2-transferv2026.08.06.1· 15d agoMODELS
01README

Backblaze B2 data-plane transfers via the Native API v4 — the thirteen upload, download and large-file operations, guarded. Inventories the interrupted large uploads B2 bills for invisibly, proves a bucket is readable and writable end to end, and refuses to move more than 100 MB without an explicit override.

02Release Notes

First publish of @sntxrr/b2/transfer — the B2 data plane, completing this suite's coverage of all 33 Native API v4 operations.

Thirteen operations across seven methods: scan, upload, download, authorize_download, list_parts, copy_part, delete.

Guarded on purpose. Streaming multi-gigabyte objects through a Deno subprocess produces no meaningful typed state, and restic already moves those bytes over S3, so upload and download refuse anything over maxTransferBytes (100 MB default) — checked before b2_authorize_account, which is itself class-C, so a refused transfer costs nothing at all. A pre-flight check also rejects a model-level cap above 1 GiB, because raising it permanently is how a guarded validation tool quietly becomes an unguarded data mover.

What it is for: proving a bucket is readable and writable independently of restic (upload a canary, download it, compare the SHA-1), and surfacing interrupted large uploads — which B2 stores and bills indefinitely, and which appear in neither b2_list_file_names nor the console's file browser. On the estate this was built for, scan found ten stuck since 2021.

The download authorization token is never persisted. Unlike an application key's one-shot secret it can be re-minted at will, so storing a copy is all risk and no benefit. Enforced as tokenPersisted: z.literal(false).

Honest nulls throughout: sha1Verified null means NOT CHECKED, distinct from false meaning checked-and-mismatched — branch on === false. partCount null means list_parts was never run, not zero parts.

Live-verified end to end in a purpose-built scratch bucket: small upload with SHA-1 verification, multi-part upload from a local file, download by id and by name, a byte-for-byte round trip, a minted-and-verified download authorization, server-side assembly from two source ranges compared byte-for-byte against a locally built expectation, plus ten real cancels and a repeat cancel on the production fleet.

Live exercise found three defects mocks could not: delete was not idempotent (B2 returns catch-all bad_request, not file_not_present, for an already-cancelled file); a pre-flight check gating delete on an acknowledgement made the documented per-run path impossible and forced arming destruction permanently; and copy_part was outright unreachable, so it now owns the whole start/copy/finish lifecycle.

03Models1
@sntxrr/b2/transferv2026.08.06.1b2_transfer.ts

Global Arguments

ArgumentTypeDescription
applicationKeyIdstringB2 application key ID (master or scoped). See the README for the
applicationKeystringB2 application key — supply via vault.get(), never inline.
authHost?stringOverride the B2 authorize host (testing only). Defaults to
bucketName?stringBucket this model manages. Required by upload, download by name,
bucketId?stringBucket ID matching bucketName. Supplying it saves one class-C
maxTransferBytes?numberRefuse any single upload or download larger than this many bytes.
allowTransferDestruction?booleanAcknowledge that delete cancels an in-flight large upload and discards

Resources

unfinished-upload(infinite)— An interrupted large upload B2 is still storing and still billing, instance-named unfinished-upload-<fileId>
transfer(infinite)— The outcome of one upload, download or copy_part — its shape and integrity, never its payload
download-auth(infinite)— A minted download authorization's scope and expiry. Never its token — the token is regenerable and is deliberately not persisted
04Stats
A
100 / 100
Downloads
0
Archive size
47.5 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository2/2earned
05Platforms
06Labels