Skip to content

Commit

Permalink
Mention option to pass streams into FormData
Browse files Browse the repository at this point in the history
  • Loading branch information
JaoodxD committed Apr 10, 2024
1 parent 48af032 commit 6bfc2e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ const data = {
await fetch('https://example.com', { body: data, method: 'POST', duplex: 'half' })
```

[FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) besides text data and buffers can also utilize streams via [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects:

```js
import { openAsBlob } from 'node:fs'

const file = await openAsBlob('./big.csv')
const body = new FormData()
body.set('file', file, 'big.csv')

await fetch('http://example.com', { method: 'POST', body })
```

#### `request.duplex`

- half
Expand Down

0 comments on commit 6bfc2e8

Please sign in to comment.