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

    Interface ContentSource

    Uniform adapter for upload content. Wraps File, Blob, Buffer, 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(): 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) — the multipart upload engine can dispatch part reads in parallel by slicing the source into disjoint ranges. false for forward-only sources (StreamSource) — 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.

      Returns Promise<ArrayBuffer>