4.4.0
Update
-
Backport
File.webkitRelativePath
property for better types compatibility with nativeFormData
-
Backport improvements for
instanceof
checks onFile
object: It now will recognizeFile
-ish objects and Files asFile
instance, but notBlob
orBlob
-ish objects:Old behaviour:
import {Blob, File} from "formdata-node" const file = new File(["File content"], "file.txt") const blob = new Blob() file instanceof Blob // -> true file instanceof File // -> true blob instanceof Blob // -> true blob instanceof File // -> true const fileLike = { [Symbol.toStringTag]: "File", name: "file.txt", stream() { } } const blobLike = { [Symbol.toStringTag]: "Blob", stream() { } } fileLike instanceof Blob // -> true fileLike instanceof File // -> true blobLike instanceof Blob // -> true blobLike instanceof File // -> true
New behaviour:
import {Blob, File} from "formdata-node" const file = new File(["File content"], "file.txt") const blob = new Blob() file instanceof Blob // -> true file instanceof File // -> true blob instanceof Blob // -> true blob instanceof File // -> false const fileLike = { [Symbol.toStringTag]: "File", name: "file.txt", stream() { } } const blobLike = { [Symbol.toStringTag]: "Blob", stream() { } } fileLike instanceof Blob // -> true fileLike instanceof File // -> true blobLike instanceof Blob // -> true blobLike instanceof File // -> false
-
Backport
File
values normalization for better alignment with the spec. FormData instances will storeFiles
added via.set()
and.append()
methods as is.Old behaviour:
import {FormData, File} from "formdata-node" const file = new File(["File content"], "file.txt") const form = new FormData() form.set("file", file) // will create a new File, then store that new object form.get("file") === file // -> false form.set("file", file, "renamed-file.txt") // will also create a new File (with the new name), then store that new object form.get("file") === file // -> false
New behaviour:
import {FormData, File} from "formdata-node" const file = new File(["File content"], "file.txt") const form = new FormData() form.set("file", file) // will store this File instance as is form.get("file") === file // -> true form.set("file", file, "renamed-file.txt") // will create a new File (with the new name), then store that new object form.get("file") === file // -> false
All changes: v4.3.3...v4.4.0