Files
bun-src/docs/guides/binary/blob-to-dataview.mdx
T
2026-08-27 21:09:14 +00:00

17 lines
505 B
Plaintext

---
title: Convert a Blob to a DataView
sidebarTitle: "Blob to DataView"
mode: center
---
The [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) class provides several methods for consuming its contents in different formats. Read the contents into an `ArrayBuffer` with `.arrayBuffer()`, then create a `DataView` from the buffer.
```ts
const blob = new Blob(["hello world"]);
const arr = new DataView(await blob.arrayBuffer());
```
---
See [Binary Data](/runtime/binary-data#conversion).