Javascript SDK

BlobLink

Reference a blob.

const blobLink = {
  hash: "2c29c30097484dad91d5b4f1e4c4560c0b1ffdeda4c447e396fea6ce38004583",
  type: "image/jpeg",
  name: "thumbnail.jpg",
};

Static methods

  • new(response: BlobResponse, type: string, name: string): BlobLink

    • Create a new blob link from a blob upload response.

Properties

  • hash BlobHash

    • SHA256 hash of the blob content.
  • type string

    • MIME type to use when serving the blob.
  • name string

    • Filename to use when serving the blob.

Notes

  • A given record can link to the same blob multiple times with different type and name attributes. Those will be used to correctly serve the blob when requested.

Once created, a blob link can immediately be used in the content of a record that accepts a link of the same type. In this example, we upload a File­ and create a File record­.

import {BlobLink} from "@baqhub/sdk";
import {FileRecord} from "./baq/fileRecord.js";

async function uploadFile(client, entity, file) {
  const response = await client.uploadBlob(file);
  const blobLink = BlobLink.new(response, file.type, file.name);

  return FileRecord.new(entity, {
    blob: blobLink,
    size: response.size,
  });
}
© 2024 Quentez