# resource/blobasset (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/resource/blobasset/

Blob asset. (binary)

## BlobAsset extends Asset

Blob asset. (binary)

Example: Fetch a file as a blob

```js
import { BlobAsset } from "./build/vanilla.js";

const blobAsset = new BlobAsset();
await blobAsset.load("examples/assets/beep.wav");
const blob = blobAsset.getBlob();
console.log(blob.size, blob.type, blobAsset.isLoaded());
```

- `constructor()` (constructor, since 0.0.9): Constructor.
- `async load(assetPath)` (method, since 0.0.9): Loads the asset asynchronously.
  - `assetPath` string: File path. (does nothing if already loaded)
  - returns Promise<void>: A promise resolved when fully fetched. (on a failed response it reports with console.error and rejects)
- `loadFromBytes(assetPath, bytes)` (method, since 0.4.0): Loads from bytes already held. (Replaces with the new bytes even if already loaded)
  - `assetPath` string: Name used for getAssetPath.
  - `bytes` ArrayBuffer | ArrayBufferView | Blob: Bytes of the file. (used as is if a Blob, otherwise wrapped in a Blob)
- `getBlob()` (method, since 0.0.9): Returns the blob.
  - returns Blob: The fetched blob. (null before loading)
