Releases: octet-stream/form-data-encoder
Releases · octet-stream/form-data-encoder
2.1.1
2.1.0
Update
- Fix a bug with
NaN
returned asContent-Length
value whenFormDataEncoder
discovers entries without known length.
All changes: v2.0.1...v2.1.0
2.0.1
2.0.0
Breaking
- Drop CommonJS support. The package is now ESM only;
- Remove
Encoder
from exports; - Remove deprecated
isFormDataLike
helper. UseisFormData
instead.
Update
- Minimal required Node.js version is 14.18;
- Headers in
FormDataEncoder.headers
property can be accessed in case-insensitive manner. TypeScript users still have correct TS typings, but only for original and lowercased keys (for exampleContent-Type
andcontent-type
); FormData
instance will be preserved in array inside ofFormDataEncoder
instance (previously it held a reference to givenFormData
instance);- Deprecate
isFileLike
helper. UseisFile
instead; - Deprecate
FormDataEncoder.getContentLength()
method. The content-length is now static value, so this method makes no sense. UseFormDataEncoder.contentLength
orFormDataEncoder.headers["content-length"]
instead.
Add
- Expose
FormDataEncoderHeaders
type.
All changes: v1.7.2...v2.0.0
1.7.2
Update
- Replace negative lookbehind with replacer function in
normalizeValue
utility, because it of the compatibility issues in Safari (See: #5)
All changes: v1.7.1...v1.7.2
1.7.1
1.7.0
Update
- Use only lowercased alphabetical + numeric characters in
createBoundary
function to improve compatibility with existentBlob
implementation as it's one of the supported targets; - In-code documentation improvements;
All changes: v1.6.0...v1.7.0
1.6.0
Add
- Add
options
argument forFormDataEncoder
constructor; - Add support for per part
Content-Length
header. It turned off by default, because it is not spec-compliant extension - the web clients does not include it. UseenableAdditionalHeaders
option to enable this header:
import {Readable} from "stream"
import {FormDataEncoder} from "form-data-encoder"
import {FormData, File} from "formdata-node"
const form = new FormData()
const file = new File(["My hovercraft is full of eels"], "file.txt", {type: "text/plain"})
form.set("field", "Some field")
form.set("file", file)
// You can pass options as the second or third argument
const encoder = new FormDataEncoder(form, {enableAdditionalHeaders: true})
Readable.from(encoder).pipe(process.stdout)
Outputs:
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="field"
Content-Length: 10
Some field
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="file"; filename="file.txt"
Content-Type: text/plain
Content-Length: 29
My hovercraft if full of eels
--form-data-boundary-ZrZBNwvvIVAsVl6f--
To find more information about additional headers per form-data part, see:
All changes: v1.5.4...v1.6.0