@triply/triplydb
    Preparing search index...

    Class Asset

    A file attached to a Dataset, stored alongside its graphs and versioned.

    Obtain one with Dataset.getAsset, iterate them with Dataset.getAssets, or create one with Dataset.uploadAsset. Assets are never constructed directly.

    const dataset = await account.getDataset("my-dataset");
    const asset = await dataset.getAsset("logo.png");
    await asset.toFile("./logo.png");
    const asset = await dataset.uploadAsset("./logo.png", {
    name: "logo.png",
    mode: "replace-if-exists",
    });
    Index
    • Adds a new version of this asset, keeping the previous ones.

      Parameters

      • fileOrPath: string | File

        Path to the file, or a File object.

      Returns Promise<Asset>

      This asset, now with the new version as its latest.

      If the asset has been deleted.

    • Deletes a version of this asset, or the whole asset.

      Parameters

      • OptionalversionNumber: number

        Zero-based version to delete, or omit for the whole asset.

      Returns Promise<Asset | undefined>

      Destructive and not undoable. With no argument this deletes the entire asset and every version — unless Asset.selectVersion was called, in which case it deletes only that version. Once the last version is gone the asset no longer exists and every method on this object throws.

    • This asset's metadata, merged with one version's.

      Parameters

      • OptionalversionNumber: number

        Which version to report; the one set by Asset.selectVersion, or the latest, when omitted.

      Returns AssetInfo & Omit<AssetVersion, "id">

      Reads from what was already fetched rather than making a request, so it is synchronous.

      If the asset has been deleted.

    • Metadata for one version: when it was uploaded, by whom, and how large it is.

      Parameters

      • versionNumber: number

        Zero-based version index, so the first upload is 0.

      Returns AssetVersion

      If the asset has no such version, or has been deleted.

    • Makes this version the one other methods act on.

      Parameters

      • versionNumber: number

        Zero-based version index.

      Returns Asset

      This asset, for chaining.

      Mutates this object rather than returning a new one, and it sticks: a later Asset.delete with no argument then removes this version instead of the whole asset.

      If the asset has no such version.

    • Downloads this asset to a file.

      Parameters

      • destinationPath: string

        Where to write it.

      • OptionalversionNumber: number

        Which version to download; the selected or latest one when omitted.

      Returns Promise<void>

    • Downloads this asset as a stream, for a file too large to hold in memory.

      Parameters

      • OptionalversionNumber: number

        Which version to read; the selected or latest one when omitted.

      Returns Promise<WriteStream>