# resource/blobasset (vanilla.js 0.4.0)

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

블롭 애셋. (바이너리)

## BlobAsset extends Asset

블롭 애셋. (바이너리)

예제: 파일을 블롭으로 받기

```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): 생성.
- `async load(assetPath)` (method, since 0.0.9): 비동기 애셋 로드.
  - `assetPath` string: 파일 경로. (이미 읽혔으면 아무것도 하지 않는다)
  - returns Promise<void>: 다 받으면 풀리는 프로미스. (실패 응답이면 console.error 로 알리고 거부된다)
- `loadFromBytes(assetPath, bytes)` (method, since 0.4.0): 이미 가진 바이트로 읽기. (이미 읽혔어도 새 바이트로 바꾼다)
  - `assetPath` string: getAssetPath 에 쓸 이름.
  - `bytes` ArrayBuffer | ArrayBufferView | Blob: 파일의 바이트. (Blob 이면 그대로 쓰고, 아니면 Blob 으로 감싼다)
- `getBlob()` (method, since 0.0.9): 블롭 반환.
  - returns Blob: 받은 블롭. (읽기 전이면 null)
