Reference a blob.
const blobLink = {
hash: "2c29c30097484dad91d5b4f1e4c4560c0b1ffdeda4c447e396fea6ce38004583",
type: "image/jpeg",
name: "thumbnail.jpg",
};
BlobLink
new(response: BlobResponse, type: string, name: string)
: BlobLink
hash
BlobHash
type
string
name
string
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,
});
}