Cancellation
An AbortSignal always fails the call fast at the Files layer; whether the underlying provider request is also cancelled depends on the adapter.
Pass a signal to bind a call to an AbortController. The moment it aborts, the in-flight call rejects with a FilesError carrying aborted: true — for every adapter, whether or not the provider's SDK supports cancellation.
const controller = new AbortController();
const upload = files.upload("avatars/abc.png", file, {
signal: controller.signal,
});
// Later, abort it — the call rejects immediately.
controller.abort();Detecting an abort
An aborted call rejects with a Provider FilesError whose aborted flag is true. That flag, not the code, is what distinguishes a cancellation (or a timeout) from a real provider failure.
import { FilesError } from "files-sdk";
try {
await files.download("big.zip", { signal: controller.signal });
} catch (err) {
if (err instanceof FilesError && err.aborted) {
return; // expected — the caller (or a timeout) aborted it
}
throw err;
}Constructor and per-call signals
signal can also be set on the constructor, where it applies to every single-key operation the instance runs — handy for tearing down all in-flight work when a request or job ends. When both a constructor signal and a per-call signal are present, either one aborting cancels the call.
const files = new Files({
adapter: s3({ bucket: "uploads" }),
signal: req.signal, // bind every operation to the request lifecycle
});The array forms (upload([…]), delete([…]), …) don't take a per-call signal; they manage work through concurrency / stopOnError instead. Cancellation is a single-key concern.
What the adapter does downstream
Failing fast at the Files layer is guaranteed; cancelling the provider request underneath is not. Adapters whose SDK exposes cancellation forward the signal directly — the S3 adapter and the whole S3-compatible catalog (R2 over HTTP, MinIO, Spaces, and every regional / budget / decentralised wrapper), Vercel Blob, and UploadThing's fetch-backed reads. Adapters whose SDK has no cancellation primitive (for example UploadThing's delete) still reject at the Files layer the instant the signal aborts, but the provider request may run to completion in the background.
Aborts are never retried — see Retries — and a timeout aborts the call the same way when it fires.
Bulk actions
Pass an array instead of a key to act on many objects in one call - a bounded fan-out that keeps successes and failures separate, in input order, and never sinks the whole batch on one bad key.
Escape hatch
Drop down to the native, per-adapter client for any feature outside the unified surface — versioning, lifecycle rules, ACLs, object tags, and more.