Bytes class Stay organized with collections Save and categorize content based on your preferences.
An immutable object representing an array of bytes.
Signature:
exportdeclareclassBytesMethods
| Method | Modifiers | Description |
|---|---|---|
| fromBase64String(base64) | static | Creates a newBytes object from the given Base64 string, converting it to bytes. |
| fromJSON(json) | static | Builds aBytes instance from a JSON object created byBytes.toJSON(). |
| fromUint8Array(array) | static | Creates a newBytes object from the given Uint8Array. |
| isEqual(other) | Returns true if thisBytes object is equal to the provided one. | |
| toBase64() | Returns the underlying bytes as a Base64-encoded string. | |
| toJSON() | Returns a JSON-serializable representation of thisBytes instance. | |
| toString() | Returns a string representation of theBytes object. | |
| toUint8Array() | Returns the underlying bytes in a newUint8Array. |
Bytes.fromBase64String()
Creates a newBytes object from the given Base64 string, converting it to bytes.
Signature:
staticfromBase64String(base64:string):Bytes;Parameters
| Parameter | Type | Description |
|---|---|---|
| base64 | string | The Base64 string used to create theBytes object. |
Returns:
Bytes.fromJSON()
Builds aBytes instance from a JSON object created byBytes.toJSON().
Signature:
staticfromJSON(json:object):Bytes;Parameters
| Parameter | Type | Description |
|---|---|---|
| json | object | a JSON object represention of aBytes instance |
Returns:
an instance ofBytes if the JSON object could be parsed. Throws aFirestoreError if an error occurs.
Bytes.fromUint8Array()
Creates a newBytes object from the given Uint8Array.
Signature:
staticfromUint8Array(array:Uint8Array):Bytes;Parameters
| Parameter | Type | Description |
|---|---|---|
| array | Uint8Array | The Uint8Array used to create theBytes object. |
Returns:
Bytes.isEqual()
Returns true if thisBytes object is equal to the provided one.
Signature:
isEqual(other:Bytes):boolean;Parameters
| Parameter | Type | Description |
|---|---|---|
| other | Bytes | TheBytes object to compare against. |
Returns:
boolean
true if thisBytes object is equal to the provided one.
Bytes.toBase64()
Returns the underlying bytes as a Base64-encoded string.
Signature:
toBase64():string;Returns:
string
The Base64-encoded string created from theBytes object.
Bytes.toJSON()
Returns a JSON-serializable representation of thisBytes instance.
Signature:
toJSON():object;Returns:
object
a JSON representation of this object.
Bytes.toString()
Returns a string representation of theBytes object.
Signature:
toString():string;Returns:
string
A string representation of theBytes object.
Bytes.toUint8Array()
Returns the underlying bytes in a newUint8Array.
Signature:
toUint8Array():Uint8Array;Returns:
Uint8Array
The Uint8Array created from theBytes object.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-30 UTC.