Blob
ClassRepresents 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
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
| Parameter | Type |
|---|---|
blobParts? | (string | Uint8Array<ArrayBufferLike> | Blob)[] |
options? | any |
Returns
Blob
Overrides
ScriptObject.constructor
Properties
size
readonlysize:number
SPECSCamera Kit
The size of the blob's data in bytes.
type
readonlytype: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()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
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>