Closed Val-istar-Guo closed 2 years ago
https://github.com/octet-stream/form-data/blob/b925ce9c541f11a6be1b87cfc159334a3a573087/lib/isFile.ts#L8
import fetch from 'node-fetch' import { FormData, Blob } from "formdata-node" const form = new FormData() const blob = new Blob(["Some content"], {type: "text/plain"}) form.set("blob", blob) const encoder = new FormDataEncoder(form) const options = { method: "post", headers: encoder.headers, body: Readable.from(encoder) } const res = await fetch("https://httpbin.org/post", options) const imgBlob = res.blob() const nextForm = new FormData() nextForm.set("nextRequestBlob", imgBlob) const nextEncoder = new FormDataEncoder(nextForm) const nextOptions = { method: "post", headers: nextEncoder.headers, body: Readable.from(nextEncoder) } // will error await fetch("https://httpbin.org/post", nextOptions)
The way to fix the problem is not cumbersome, but not elegant
const imgBuf = res.buffer() const nextForm = new FormData() nextForm.set("nextRequestBlob", imgBuf)
The reason of the problem is due to the fact that node-fetch also provides a Blob implementation:
https://github.com/node-fetch/node-fetch/blob/2.x/src/blob.js
Are there plans to fix this?
I have the error of using
https://github.com/octet-stream/form-data/blob/b925ce9c541f11a6be1b87cfc159334a3a573087/lib/isFile.ts#L8
The way to fix the problem is not cumbersome, but not elegant
The reason of the problem is due to the fact that node-fetch also provides a Blob implementation:
https://github.com/node-fetch/node-fetch/blob/2.x/src/blob.js
Are there plans to fix this?