Skip to content

Commit d1f83b2

Browse files
committed
Fix for 3rd example
1 parent f5f7f6c commit d1f83b2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ await fetch("https://httpbin.org/post", options)
7070
3. Because the Encoder is async iterable, you can use it with different targets. Let's say you want to put FormData content into `Blob`, for that you can write a function like this:
7171

7272
```js
73+
import {randomType} from "crypto"
74+
7375
import {FormData} from "formdata-polyfill/esm-min.js"
7476
import {blobFrom} from "fetch-blob/from.js"
7577
import {Encoder} from "form-data-encoder"
@@ -78,7 +80,9 @@ import {Blob} from "fetch-blob" // For this example I will use v3 of this packag
7880
import fetch from "node-fetch"
7981

8082
async function toBlob(form) {
81-
const encoder = new Encoder(form)
83+
// Note that Blob will lowercase the boundary string before assign it to Blob#type property. So you may need to bring your own boundary string, which must contain only lowercase alphabetic characters.
84+
const boundary = randomBytes(16).toString("hex")
85+
const encoder = new Encoder(form, boundary)
8286
const chunks = []
8387

8488
for await (const chunk of encoder) {

0 commit comments

Comments
 (0)