> Documentation index: https://firebase.google.com/docs/reference/llms.txt

# Blob


```
public class Blob implements Comparable
```

<br />

*** ** * ** ***

Immutable class representing an array of bytes in Cloud Firestore.

Can represent either standard binary data or BSON binary data with a specific subtype.

## Summary

| ### Public methods |
|---|---|
| `int` | `compareTo(@NonNull Blob other)` |
| `static @NonNull Blob` | `createBsonBinary(@NonNull byte[] bytes)` Creates a BSON Binary type `Blob` with subtype 0. |
| `static @NonNull Blob` | `createBsonBinary(int subtype, @NonNull byte[] bytes)` Creates a BSON Binary type `Blob` with the specified subtype. |
| `boolean` | `equals(@Nullable Object other)` |
| `static @NonNull Blob` | `fromBytes(@NonNull byte[] bytes)` Creates a new `Blob` instance from the provided bytes. |
| `int` | `getSubType()` Returns the subtype of this BSON binary data. |
| `int` | `hashCode()` |
| `@NonNull byte[]` | `toBytes()` |
| `@NonNull String` | `toString()` |

## Public methods

### compareTo

```
public int compareTo(@NonNull Blob other)
```

### createBsonBinary

```
public static @NonNull Blob createBsonBinary(@NonNull byte[] bytes)
```

Creates a BSON Binary type `Blob` with subtype 0. Will make a copy of the bytes passed in.

| Parameters |
|---|---|
| `@NonNull byte[] bytes` | The bytes to use for this BSON binary `Blob` instance. |

| Returns |
|---|---|
| `@NonNull Blob` | The new BSON binary `Blob` instance |

### createBsonBinary

```
public static @NonNull Blob createBsonBinary(int subtype, @NonNull byte[] bytes)
```

Creates a BSON Binary type `Blob` with the specified subtype. Will make a copy of the bytes passed in.

| Parameters |
|---|---|
| `int subtype` | The BSON binary subtype. Must be in the \[0, 255\] range. |
| `@NonNull byte[] bytes` | The bytes to use for this BSON binary `Blob` instance. |

| Returns |
|---|---|
| `@NonNull Blob` | The new BSON binary `Blob` instance |

### equals

```
public boolean equals(@Nullable Object other)
```

### fromBytes

```
public static @NonNull Blob fromBytes(@NonNull byte[] bytes)
```

Creates a new `Blob` instance from the provided bytes. Will make a copy of the bytes passed in.

By default, the subtype of a standard `Blob` is 0.

| Parameters |
|---|---|
| `@NonNull byte[] bytes` | The bytes to use for this `Blob` instance. |

| Returns |
|---|---|
| `@NonNull Blob` | The new `Blob` instance |

### getSubType

```
public int getSubType()
```

Returns the subtype of this BSON binary data. Returns 0 for standard non-BSON `Blob`s.

| Returns |
|---|---|
| `int` | The BSON binary subtype. |

### hashCode

```
public int hashCode()
```

### toBytes

```
public @NonNull byte[] toBytes()
```

| Returns |
|---|---|
| `@NonNull byte[]` | The bytes of this blob as a new `byte[]` array. |

### toString

```
public @NonNull String toString()
```