Closed
Description
@jimmywarting As I mentioned here, I'm running into the problem when using this package with node-fetch. The problem remains both in the latest stable and beta. With fetch-blob@3.0.0-rc.0
and fetch-blob@2.1.1
.
I was trying to test an example for my form-data-encoder
where the encoder targeting Blob
as you did in formdata-polyfill:
import {Readable} from "stream"
import {FormData, fileFromPath} from "formdata-node"
import {Encoder} from "form-data-encoder"
import Blob from "fetch-blob"
import fetch from "node-fetch"
async function toBlob(form) {
const encoder = new Encoder(form)
const chunks = []
for await (const chunk of encoder) {
chunks.push(chunk)
}
return new Blob(chunks, {type: encoder.contentType})
}
const fd = new FormData()
fd.set("name", "John Doe")
fd.set("avatar", await fileFromPath("avatar.png"))
const options = {
method: "post",
body: await toBlob(fd)
}
const response = await fetch("https://httpbin.org/post", options)
console.log(await response.text())
When I run this code node test.mjs
this happens:
- With fetch-blob I get the following error:
body.stream().pipe(dest);
. This error appears innode-fetch/src/body.js:374:17
- When I run the same code, but with
fetch-blob@2.1.1
it will lowercase the value ofBlob#type
which breaks boundary string returned by form-data-encoder.
Metadata
Metadata
Assignees
Labels
No labels