2.0.0
Remove
- Drop Node.js 8 support. The minimal supported version is now 10.
Add
-
FormData#{set,append}()now takes an optional 4th (or 3rd) argument – options:type Options = { size?: number, type?: string, lastModified?: number, filename?: string }
This argument is used to put additional information for stream values.
Streams will be considered as a File-ish objects when this option is set.
If given value isBuffer,Blob-ish orFile-ish object, its own properties will be used to get the size.
Update
-
FormDatanow storesBufferandBlob-ish objects like aFile-ish.
So, when you use theFormData#{get,getAll}()methods or iterate through FormData values
you will getFile-ish object instead ofBlob,File,Bufferand streams:import fs from "fs" import FormData from "formdata-node" import Blob from "fetch-blob" const fd = new FormData() fd.set("buffer", Buffer.from("I beat Twilight Sparkle and all I got was this lousy t-shirt")) fd.get("buffer") // -> File fd.set("blob", new Blob(["I beat Twilight Sparkle and all I got was this lousy t-shirt"], {type: "text/plain"})) fd.get("blob") // -> File // The "size" option required for stream values if you want them to be set as a File fd.set("readStream", fs.createReadStream("/path/to/some/file.txt")) fd.get("readStream") // -> ReadStream fd.set("readStream", fs.createReadStream("/path/to/some/file.txt"), { size: fs.statSync("/path/to/some/file.txt").size }) fd.get("readStream") // -> File
-
Fix a typo in default content-type value 51e01a7;
-
Improve error messaging and arguments checking for
FormData#{set,append}()methods.
All changes: v1.8.1...v2.0.0