Core - v1.0.0
    Preparing search index...

    Interface ObjectStore<TRuntime>

    Blob storage for files and payloads too large to sit in a row or a cache.

    The body types are the Web-platform ones rather than anything vendor-specific, which is what lets the same interface describe an edge object store and a local filesystem stub without either having to translate.

    Bayu Dwiyan Satria

    1.0.0

    1.0.0

    interface ObjectStore<TRuntime = unknown> {
        download(runtime: TRuntime, key: string): Promise<string>;
        downloadJson<T = unknown>(runtime: TRuntime, key: string): Promise<T>;
        exists(runtime: TRuntime, key: string): Promise<boolean>;
        isAvailable(runtime: TRuntime): boolean;
        list(runtime: TRuntime, prefix: string): Promise<StoredObject[]>;
        remove(runtime: TRuntime, keys: string | string[]): Promise<void>;
        upload(
            runtime: TRuntime,
            key: string,
            body: string | ArrayBufferView | ArrayBuffer | ReadableStream<any> | Blob,
            contentType?: string,
        ): Promise<StoredObject>;
        uploadJson(
            runtime: TRuntime,
            key: string,
            value: unknown,
        ): Promise<StoredObject>;
    }

    Type Parameters

    • TRuntime = unknown

      The runtime handle the store is resolved from.

    Hierarchy (View Summary)

    Index
    • Reads an object as JSON.

      Type Parameters

      • T = unknown

      Parameters

      • runtime: TRuntime

        The runtime handle.

      • key: string

        The object key.

      Returns Promise<T>

      The parsed value, or null when the object does not exist.

    • Reports whether an object exists, without transferring its body.

      Parameters

      • runtime: TRuntime

        The runtime handle.

      • key: string

        The object key.

      Returns Promise<boolean>

      true when the object is present.

    • Reports whether the capability is actually usable on this runtime.

      Parameters

      Returns boolean

      true when calls will reach a real backing resource.

      A capability backed by an optional resource answers false when that resource was never provisioned. Implementations must document what each method does in that state — degrade or throw — and must not vary it, since a caller choosing between two implementations is relying on the answer meaning the same thing in both.

    • Deletes one or more objects. Deleting an absent key is not an error.

      Parameters

      • runtime: TRuntime

        The runtime handle.

      • keys: string | string[]

        The object key, or several of them.

      Returns Promise<void>

    • Stores an object.

      Parameters

      • runtime: TRuntime

        The runtime handle.

      • key: string

        The object key.

      • body: string | ArrayBufferView | ArrayBuffer | ReadableStream<any> | Blob

        The object body.

      • OptionalcontentType: string

        MIME type recorded on the object.

      Returns Promise<StoredObject>

      The stored object's key and size.