@backblaze-labs/b2-sdk - v0.2.0
    Preparing search index...

    Interface ContentSource

    Uniform adapter for upload content. Wraps File, Blob, Buffer, local files, async iterables, or ReadableStream behind a common interface so upload logic does not depend on the input type.

    interface ContentSource {
        canSlice: boolean;
        sha1?: string;
        size: number;
        slice(start: number, end: number): ContentSource;
        stream(): ReadableStream<Uint8Array<ArrayBufferLike>>;
        toArrayBuffer(options?: { signal?: AbortSignal }): Promise<ArrayBuffer>;
    }

    Implemented by

    Index

    Properties

    canSlice: boolean

    Whether slice is safe to call on this source.

    true for in-memory / random-access sources (BufferSource, BlobSource, FileSource) — the multipart upload engine can dispatch part reads in parallel by slicing the source into disjoint ranges. false for forward-only streams and async iterables — the engine must read sequentially, one partSize chunk at a time. Callers that branch on this flag are expected to fall back to the sequential path rather than call slice() and catch the throw.

    sha1?: string

    Pre-computed SHA-1 hex digest, if available.

    size: number

    Total size of the content in bytes.

    Methods

    • Open the content as a ReadableStream.

      Returns ReadableStream<Uint8Array<ArrayBufferLike>>

    • Read the entire content into an ArrayBuffer.

      Parameters

      • Optionaloptions: { signal?: AbortSignal }

      Returns Promise<ArrayBuffer>