Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.
The file version ID to download.
Total file size in bytes (needed to compute range boundaries).
Optionaloptions: { concurrency?: number; rangeSize?: number; signal?: AbortSignal }Concurrency, range size, and abort signal.
Optionalconcurrency?: numberNumber of concurrent range requests. Defaults to 4.
OptionalrangeSize?: numberSize of each ranged GET request in bytes. Defaults to 8 MB.
Optionalsignal?: AbortSignalAbort signal for cancelling the download.
A Web ReadableStream of file data in sequential order.
Creates a Web WritableStream that uploads streamed data into this file
using the multipart protocol. Pipe a ReadableStream<Uint8Array> into the
returned writable and await done to get the final FileVersion.
Note: streaming uploads do not support resume because the size and per-part hashes are not known in advance. Use upload with a buffered source when resume is required.
Optionaloptions: {Streaming upload parameters (part size, concurrency, encryption).
Optionalconcurrency?: numberMaximum number of parts uploaded in parallel. Defaults to 4.
OptionalcontentType?: stringMIME type. Defaults to b2/x-auto.
OptionalfileInfo?: Record<string, string>Custom key-value metadata stored with the file.
OptionalonProgress?: ProgressListenerCallback invoked with upload progress events.
OptionalpartSize?: numberTarget part size in bytes. Defaults to the account's recommended part size.
OptionalserverSideEncryption?: EncryptionSettingServer-side encryption applied to each part.
Optionalsignal?: AbortSignalAbort signal that cancels the upload and the unfinished large file.
A handle with the writable sink and a completion promise.
Permanently deletes a specific version of this file.
The unique identifier of the file version to delete.
Downloads this file by name. Pass method: 'HEAD' to fetch only the
response headers (file metadata) without streaming the body.
Optionaloptions: DownloadCallOptionsOptional method, range, SSE-C decryption, response-header overrides, and abort signal.
The download result with response headers and body stream.
Downloads a specific version of this file by ID. Pass method: 'HEAD'
to fetch only the response headers (file metadata) without streaming the body.
The file version ID to download.
Optionaloptions: DownloadCallOptionsOptional method, range, SSE-C decryption, response-header overrides, and abort signal.
The download result with response headers and body stream.
Retrieves metadata for a specific file version.
The file version ID to look up.
The file version metadata.
Fetches response headers for this file via HTTP HEAD. Returns a body-less result so callers never have to drain the (logically empty) HEAD body themselves.
Optionaloptions: HeadCallOptionsOptional range, SSE-C decryption, response-header
overrides, and abort signal. Same shape as B2Object.download's
options minus method (always HEAD) and onProgress (no body).
Parsed download headers (content type, SHA-1, file info, etc.).
Fetches response headers for a specific version of this file by ID via HTTP HEAD. Returns a body-less result so callers never have to drain the (logically empty) HEAD body themselves.
The file version ID to inspect.
Optionaloptions: HeadCallOptionsOptional range, SSE-C decryption, response-header overrides, and abort signal.
Parsed download headers.
Hides this file by creating a hide marker at this file name.
Metadata for the newly created hide marker.
Toggles the legal hold flag on a specific file version of this file.
Legal hold is independent of retention: a file can be on legal hold
without any retention policy, and vice versa. The bucket must have
Object Lock enabled, and any caller must hold the writeFileLegalHolds
capability.
The file version to apply the flag to.
'on' to apply the hold, 'off' to remove it.
Metadata for the updated file version.
Sets or updates the Object Lock retention policy on a specific file version of this file.
The bucket must have Object Lock enabled (fileLockEnabled: true at
creation time). Governance-mode retention can be shortened or removed
by passing bypassGovernance: true together with an application key
that carries the bypassGovernance capability; compliance-mode
retention cannot be shortened by anyone until the
retainUntilTimestamp elapses.
The file version to apply the policy to.
The retention policy to apply.
Optionaloptions: { bypassGovernance?: boolean }Optional flag for shortening governance-mode retention.
Metadata for the updated file version.
Uploads data to this file name. Automatically uses multipart upload for large files.
Upload configuration including data source and optional settings.
Optionalconcurrency?: numberNumber of concurrent part uploads for large files.
OptionalcontentType?: stringMIME type. Defaults to auto-detection by B2.
OptionalfileInfo?: Record<string, string>Custom key-value metadata stored with the file.
OptionalfileRetention?: FileRetentionValueFile retention policy (requires file lock).
OptionallastModifiedMillis?: numberLast-modified timestamp in milliseconds since epoch.
OptionallegalHold?: LegalHoldValueLegal hold status.
OptionalonProgress?: ProgressListenerCallback invoked with upload progress events.
OptionalpartSize?: numberPart size override for multipart uploads, in bytes.
Optionalresume?: booleanResume an unfinished multipart upload for this file name when one exists. Only meaningful on the large-file path. Ignored on the small-file path.
OptionalresumeFileId?: LargeFileIdResume into a specific large-file ID, bypassing discovery.
Overrides the resume discovery path.
OptionalserverSideEncryption?: EncryptionSettingServer-side encryption settings.
Optionalsignal?: AbortSignalAbort signal for cancelling the upload.
Data source to upload.
Metadata for the uploaded file version.
Handle to a specific file (by name) within a B2 bucket.
Provides file-scoped upload, download, and management operations. Obtained via Bucket.file.
Example