Skip to main content

Blob

Class

Represents a blob, which is a file-like object of immutable, raw data.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: fully supported
  • Camera Kit Mobile: fully supported
  • SnapchatNot supported — Available on SPECS and Camera Kit only
  • SPECSFully supported
  • Camera Kit WebFully supported
  • Camera Kit MobileFully supported

Platform details

  • Snapchat — Not supported — Available on SPECS and Camera Kit only.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Represents a blob, which is a file-like object of immutable, raw data. Can be read as text or binary data. Currently the binary data is only supported as Uint8Array.

Index

Example

socket.onmessage = async (event) => {
if (event.data instanceof Blob) {
// Binary frame, can be retrieved as either Uint8Array or string
let bytes = await event.data.bytes();
let text = await event.data.text();

print("Received binary message, printing as text: " + text);
}
});

Extends

Constructors

Constructor

new Blob(blobParts?, options?): Blob

Parameters

ParameterType
blobParts?(string | Uint8Array<ArrayBufferLike> | Blob)[]
options?any

Returns

Blob

Overrides

ScriptObject.constructor

Properties

size

readonly size: number

SPECSCamera Kit

The size of the blob's data in bytes.


type

readonly type: string

SPECSCamera Kit

The MIME type of the blob.

Since

Lens Scripting Version 331

Methods

bytes()

bytes(): Promise<Uint8Array<ArrayBufferLike>>

SPECSCamera Kit

Returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes.

Returns

Promise<Uint8Array<ArrayBufferLike>>


getTypeName()

static getTypeName(): TypeName<Blob>

SPECSCamera Kit

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<Blob>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


text()

text(): Promise<string>

SPECSCamera Kit

Returns a Promise that resolves with a string containing the contents of the blob, interpreted as UTF-8.

Returns

Promise<string>