Skip to main content

Blobs

A binary large object is a collection of binary data stored as a single entity. They can exist for a finite amount of time or indefinitely.

Blob Types

Blob
{
organizationId: string,
id: string,
format: string,
name: string,
attributes: Record<string, string>,
createdUtc: datetime,
ttl: string,
expired: boolean,
}
CreateBlobOptions
{
format: string,
name: string,
ttl: string, // [DD.HH:MM:SS] / [HH:MM:SS]
attributes: Record<string, string>
}
BlobQueryOptions
{
attributes: Record<string, string>,
includeExpired: boolean
}

createBlob

Read-only Mode

This function is not available in read-only mode.

Creates a new Blob with binary data.

createBlob(data, options)

Parameters

NameTypeDescriptionOptional
databyte[] | stringThe binary array or string representation of the data.
optionsCreateBlobOptionsOptions to create the Blob with.

Returns The created Blob.

Example

// Create a blob with plain text string
var blob = createBlob('Hello World!');

// Store a blob with a byte array "Hello World!"
var blob = createBlob([
72, 101, 108, 108,
111, 32, 87, 111,
114, 108, 100, 33
],
{
name: "Text blob",
ttl: "00:10:00", // Expire in 10 minutes
});

deleteBlob

Read-only Mode

This function is not available in read-only mode.

Delete a Blob.

deleteBlob(blobId)

Parameters

NameTypeDescription
blobIdstringThe identifier of the Blob to delete.

Example

blobId('018215e4-3dd8-4b88-a9ae-20a9710bc92d');
danger

This performs a hard delete and will not be recoverable afterwards. Delete with caution.

blobExists

Checks whether a Blob with an identifier exists.

blobExists(blobId)

Parameters

NameTypeDescription
blobIdstringThe identifier of the Blob to check.

Returns A boolean on whether the Blob exists.

Example

var exists = blobExists('configuration');

if (exists) {
// The configuration Blob exists
}

readBlob

Reads the binary data of the blob as a binary array or can be configured to return a Base64 string.

readBlob(blobId, base64 = false)

Parameters

NameTypeDescriptionDefault
blobIdstringThe identifier of the Blob to read.
base64booleanWhether or not the blob should be returned as a Base64 string.false

Returns A byte[] array of the Blob's binary data, or a Base64 encoded string if base64 is true.

Example

// Read a blob as a binary array
var byteArray = readBlob('bf123e37-8812-4a84-b7fd-8df6ba50c5cc');

// Read a blob as a base64 encoded string
var base64Encoded = readBlob('f5fa0eeb-a088-4c79-89b0-b7571cd86c63', true);

// Decode the Base64 string
var decoded = atob(base64Encoded);

Find out more about atob here.

getBlob

Gets a Blob by its identifier.

getBlob(blobId)

Parameters

NameTypeDescription
blobIdstringThe identifier of the Model to retrieve.

Returns The Blob with the specified blobId identifier.

Example

var blob = getBlob('3ad5efe4-3d65-4996-b36b-d06a515d577b');

getBlobs

Gets a collection of Blobs using optional query criteria.

getBlobs(options)

Parameters

NameTypeDescription
optionsBlobQueryOptionsOptions for querying blobs.

Returns A collection of Blobs which meet the query criteria.

Example

var blobs = getBlobs({
attributes: {
modelId: "control-panel",
includeExpired: true
}
});