{"id":13455193,"url":"https://github.com/octet-stream/form-data","last_synced_at":"2025-05-14T19:01:59.636Z","repository":{"id":25915970,"uuid":"106886253","full_name":"octet-stream/form-data","owner":"octet-stream","description":"Spec-compliant FormData implementation for Node.js","archived":false,"fork":false,"pushed_at":"2024-11-18T02:52:06.000Z","size":2158,"stargazers_count":144,"open_issues_count":3,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T08:09:20.527Z","etag":null,"topics":["fetch","file-upload","form-data","javascript","library","nodejs","ponyfill","spec-compliant"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/formdata-node","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/octet-stream.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-14T00:48:26.000Z","updated_at":"2025-04-02T09:08:50.000Z","dependencies_parsed_at":"2023-10-14T16:28:19.571Z","dependency_job_id":"178061db-bb1e-4565-87fb-bd982ae39218","html_url":"https://github.com/octet-stream/form-data","commit_stats":{"total_commits":902,"total_committers":15,"mean_commits":60.13333333333333,"dds":0.05210643015521066,"last_synced_commit":"ae2cbce685fb545dfaeeea2683596c44260c84bc"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fform-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fform-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fform-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octet-stream%2Fform-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octet-stream","download_url":"https://codeload.github.com/octet-stream/form-data/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710399,"owners_count":21149185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fetch","file-upload","form-data","javascript","library","nodejs","ponyfill","spec-compliant"],"created_at":"2024-07-31T08:01:02.270Z","updated_at":"2025-04-13T11:45:22.176Z","avatar_url":"https://github.com/octet-stream.png","language":"TypeScript","readme":"# FormData\n\nSpec-compliant [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) implementation for Node.js\n\n[![Code Coverage](https://codecov.io/github/octet-stream/form-data/coverage.svg?branch=main)](https://codecov.io/github/octet-stream/form-data?branch=main)\n[![CI](https://github.com/octet-stream/form-data/workflows/CI/badge.svg)](https://github.com/octet-stream/form-data/actions/workflows/ci.yml)\n[![ESLint](https://github.com/octet-stream/form-data/workflows/ESLint/badge.svg)](https://github.com/octet-stream/form-data/actions/workflows/eslint.yml)\n[![TypeScript Types](https://github.com/octet-stream/form-data/actions/workflows/typescript.yml/badge.svg)](https://github.com/octet-stream/form-data/actions/workflows/typescript.yml)\n\n## Requirements\n\nFor this module to work consider polyfilling: [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream), and [DOMException](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) (if you use `file-from-path` utilities)\n\n## Highlights\n\n1. Spec-compliant: implements every method of the [`FormData interface`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).\n2. Supports Blobs and Files sourced from anywhere: you can use builtin [`fileFromPath`](#filefrompathpath-filename-options---promisefile) and [`fileFromPathSync`](#filefrompathsyncpath-filename-options---file) helpers to create a File from FS, or you can implement your `BlobDataItem` object to use a different source of data.\n3. Written on TypeScript and ships with TS typings.\n4. Isomorphic, but only re-exports native FormData object for browsers. If you need a polyfill for browsers, use [`formdata-polyfill`](https://github.com/jimmywarting/FormData)\n5. It's a [`ponyfill`](https://ponyfill.com/)! Which means, no effect has been caused on `globalThis` or native `FormData` implementation.\n\n## Blob/File support\n\nWhile `formdata-node` ships with its own `File` and `Blob` implementations, these might eventually be removed in favour of Node.js' [`Blob`](https://nodejs.org/dist/latest-v18.x/docs/api/buffer.html#class-blob) (introduced in v14.18) and File (when it will be introduced). In order to help you smoothen that transition period, our own `Blob` and `File`, as well as `FormData` itself, provides support `Blob` objects created by Node.js' implementation.\n\n## Installation\n\nYou can install this package with npm:\n\n```\nnpm install formdata-node\n```\n\nOr yarn:\n\n```\nyarn add formdata-node\n```\n\nOr pnpm\n\n```\npnpm add formdata-node\n```\n\n## ESM/CJS support\n\nThis package is build for and bundled for both ESM and CommonJS, so you can use it in both environments.\n\n## Usage\n\n1. Let's take a look at minimal example with [got](https://github.com/sindresorhus/got):\n\n```js\nimport {FormData} from \"formdata-node\"\n\n// I assume Got \u003e= 12.x is used for this example\nimport got from \"got\"\n\nconst form = new FormData()\n\nform.set(\"greeting\", \"Hello, World!\")\n\nconst data = await got.post(\"https://httpbin.org/post\", {body: form}).json()\n\nconsole.log(data.form.greeting) // =\u003e Hello, World!\n```\n\n2. If your HTTP client does not support spec-compliant FormData, you can use [`form-data-encoder`](https://github.com/octet-stream/form-data-encoder) to encode entries:\n\n```js\nimport {Readable} from \"stream\"\n\nimport {FormDataEncoder} from \"form-data-encoder\"\nimport {FormData} from \"formdata-node\"\n\n// Note that `node-fetch` \u003e= 3.x have builtin support for spec-compliant FormData, sou you'll only need the `form-data-encoder` if you use `node-fetch` \u003c= 2.x.\nimport fetch from \"node-fetch\"\n\nconst form = new FormData()\n\nform.set(\"field\", \"Some value\")\n\nconst encoder = new FormDataEncoder(form)\n\nconst options = {\n  method: \"post\",\n  headers: encoder.headers,\n  body: Readable.from(encoder)\n}\n\nawait fetch(\"https://httpbin.org/post\", options)\n```\n\n3. Sending files over form-data:\n\n```js\nimport {FormData, File} from \"formdata-node\" // You can use `File` from fetch-blob \u003e= 3.x\n\nimport fetch from \"node-fetch\"\n\nconst form = new FormData()\nconst file = new File([\"My hovercraft is full of eels\"], \"file.txt\")\n\nform.set(\"file\", file)\n\nawait fetch(\"https://httpbin.org/post\", {method: \"post\", body: form})\n```\n\n4. Blobs as field's values allowed too:\n\n```js\nimport {FormData, Blob} from \"formdata-node\" // You can use `Blob` from fetch-blob\n\nconst form = new FormData()\nconst blob = new Blob([\"Some content\"], {type: \"text/plain\"})\n\nform.set(\"blob\", blob)\n\n// Will always be returned as `File`\nlet file = form.get(\"blob\")\n\n// The created file has \"blob\" as the name by default\nconsole.log(file.name) // -\u003e blob\n\n// To change that, you need to set filename argument manually\nform.set(\"file\", blob, \"some-file.txt\")\n\nfile = form.get(\"file\")\n\nconsole.log(file.name) // -\u003e some-file.txt\n```\n\n5. You can use 3rd party Blob as FormData value, as vell as for BlobParts in out Blob implementation:\n\n```js\nimport {FormData, Blob} from \"formdata-node\"\nimport {Blob as FetchBlob} from \"fetch-blob\"\n\nconst input = new FetchBlob([\"a\", \"b\", \"c\"])\n\nconst blob = new Blob([input]) // Accepts 3rd party blobs as BlobParts\n\nawait blob.text() // -\u003e abc\n\nconst form = new FormData()\n\nform.set(\"file\", input)\n\nconst file = form.get(\"file\") // -\u003e File\n\nawait file.text() // -\u003e abc\n```\n\n6. You can also use Node.js' Blob implementation in these scenarios:\n\n```js\nimport {Blob as NodeBlob} from \"node:buffer\"\n\nimport {FormData, Blob} from \"formdata-node\"\n\nconst input = new NodeBlob([\"a\", \"b\", \"c\"])\n\nconst blob = new Blob([input]) // Accepts Node.js' Blob implementation as BlobParts\n\nawait blob.text() // -\u003e abc\n\nconst form = new FormData()\n\nform.set(\"file\", input)\n\nconst file = form.get(\"file\") // -\u003e File\n\nawait file.text() // -\u003e abc\n```\n\n7. You can also append files using `fileFromPath` or `fileFromPathSync` helpers. It does the same thing as [`fetch-blob/from`](https://github.com/node-fetch/fetch-blob#blob-part-backed-up-by-filesystem), but returns a `File` instead of `Blob`:\n\n```js\nimport {fileFromPath} from \"formdata-node/file-from-path\"\nimport {FormData} from \"formdata-node\"\n\nimport fetch from \"node-fetch\"\n\nconst form = new FormData()\n\nform.set(\"file\", await fileFromPath(\"/path/to/a/file\"))\n\nawait fetch(\"https://httpbin.org/post\", {method: \"post\", body: form})\n```\n\n8. You can still use files sourced from any stream, but unlike in v2 you'll need some extra work to achieve that:\n\n```js\nimport {Readable} from \"stream\"\n\nimport {FormData} from \"formdata-node\"\n\nclass BlobFromStream {\n  #stream\n\n  constructor(stream, size) {\n    this.#stream = stream\n    this.size = size\n  }\n\n  stream() {\n    return this.#stream\n  }\n\n  get [Symbol.toStringTag]() {\n    return \"Blob\"\n  }\n}\n\nconst content = Buffer.from(\"Stream content\")\n\nconst stream = new Readable({\n  read() {\n    this.push(content)\n    this.push(null)\n  }\n})\n\nconst form = new FormData()\n\nform.set(\"stream\", new BlobFromStream(stream, content.length), \"file.txt\")\n\nawait fetch(\"https://httpbin.org/post\", {method: \"post\", body: form})\n```\n\n9. Note that if you don't know the length of that stream, you'll also need to handle form-data encoding manually or use [`form-data-encoder`](https://github.com/octet-stream/form-data-encoder) package. This is necessary to control which headers will be sent with your HTTP request:\n\n```js\nimport {Readable} from \"stream\"\n\nimport {Encoder} from \"form-data-encoder\"\nimport {FormData} from \"formdata-node\"\n\nconst form = new FormData()\n\n// You can use file-shaped or blob-shaped objects as FormData value instead of creating separate class\nform.set(\"stream\", {\n  type: \"text/plain\",\n  name: \"file.txt\",\n  [Symbol.toStringTag]: \"File\",\n  stream() {\n    return getStreamFromSomewhere()\n  }\n})\n\nconst encoder = new Encoder(form)\n\nconst options = {\n  method: \"post\",\n  headers: {\n    \"content-type\": encoder.contentType\n  },\n  body: Readable.from(encoder)\n}\n\nawait fetch(\"https://httpbin.org/post\", {method: \"post\", body: form})\n```\n\n## Comparison\n\n|                  | formdata-node | formdata-polyfill | undici FormData | form-data            |\n| ---------------- | ------------- | ----------------- | --------------- | -------------------- |\n| .append()        | ✔️             | ✔️                 | ✔️               | ✔️\u003csup\u003e1\u003c/sup\u003e        |\n| .set()           | ✔️             | ✔️                 | ✔️               | ❌                   |\n| .get()           | ✔️             | ✔️                 | ✔️               | ❌                   |\n| .getAll()        | ✔️             | ✔️                 | ✔️               | ❌                   |\n| .forEach()       | ✔️             | ✔️                 | ✔️               | ❌                   |\n| .keys()          | ✔️             | ✔️                 | ✔️               | ❌                   |\n| .values()        | ✔️             | ✔️                 | ✔️               | ❌                   |\n| .entries()       | ✔️             | ✔️                 | ✔️               | ❌                   |\n| Symbol.iterator  | ✔️             | ✔️                 | ✔️               | ❌                   |\n| ESM              | ✔️             | ✔️                 | ✔️\u003csup\u003e2\u003c/sup\u003e   | ✔️\u003csup\u003e2\u003c/sup\u003e        |\n| Blob             | ✔️\u003csup\u003e3\u003c/sup\u003e | ✔️\u003csup\u003e4\u003c/sup\u003e     | ✔️\u003csup\u003e3\u003c/sup\u003e   | ❌                   |\n| Browser polyfill | ❌            | ✔️                 | ✔️               | ❌                   |\n| Builtin encoder  | ❌            | ✔️                 | ✔️\u003csup\u003e5\u003c/sup\u003e   | ✔️                    |\n\n\u003csup\u003e1\u003c/sup\u003e Does not support Blob and File in entry value, but allows streams and Buffer (which is not spec-compliant, however).\n\n\u003csup\u003e2\u003c/sup\u003e Can be imported in ESM, because Node.js support for CJS modules in ESM context, but it does not have ESM entry point.\n\n\u003csup\u003e3\u003c/sup\u003e Have builtin implementations of Blob and/or File, allows native Blob and File as entry value.\n\n\u003csup\u003e4\u003c/sup\u003e Support Blob and File via fetch-blob package, allows native Blob and File as entry value.\n\n\u003csup\u003e5\u003c/sup\u003e Have `multipart/form-data` encoder as part of their `fetch` implementation.\n\n✔️ - For FormData methods, indicates that the method is present and spec-compliant. For features, shows its presence.\n\n❌ - Indicates that method or feature is not implemented.\n\n## API\n\n### `class FormData`\n\n##### `constructor() -\u003e {FormData}`\n\nCreates a new FormData instance.\n\n#### Instance methods\n\n##### `set(name, value[, filename]) -\u003e {void}`\n\nSet a new value for an existing key inside **FormData**,\nor add the new field if it does not already exist.\n\n  - **{string}** name – The name of the field whose data is contained in `value`.\n  - **{unknown}** value – The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n    or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.\n  - **{string}** [filename = undefined] – The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is \"blob\". The default filename for File objects is the file's filename.\n\n##### `append(name, value[, filename]) -\u003e {void}`\n\nAppends a new value onto an existing key inside a FormData object,\nor adds the key if it does not already exist.\n\nThe difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.\n\n  - **{string}** name – The name of the field whose data is contained in `value`.\n  - **{unknown}** value – The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n    or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.\n  - **{string}** [filename = undefined] – The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is \"blob\". The default filename for File objects is the file's filename.\n\n##### `get(name) -\u003e {FormDataValue}`\n\nReturns the first value associated with a given key from within a `FormData` object.\nIf you expect multiple values and want all of them, use the `getAll()` method instead.\n\n  - **{string}** name – A name of the value you want to retrieve.\n\n##### `getAll(name) -\u003e {Array\u003cFormDataValue\u003e}`\n\nReturns all the values associated with a given key from within a `FormData` object.\n\n  - **{string}** name – A name of the value you want to retrieve.\n\n##### `has(name) -\u003e {boolean}`\n\nReturns a boolean stating whether a `FormData` object contains a certain key.\n\n  - **{string}** – A string representing the name of the key you want to test for.\n\n##### `delete(name) -\u003e {void}`\n\nDeletes a key and its value(s) from a `FormData` object.\n\n  - **{string}** name – The name of the key you want to delete.\n\n##### `forEach(callback[, thisArg]) -\u003e {void}`\n\nExecutes a given **callback** for each field of the FormData instance\n\n  - **{function}** callback – Function to execute for each element, taking three arguments:\n    + **{FormDataValue}** value – A value(s) of the current field.\n    + **{string}** name – Name of the current field.\n    + **{FormData}** form – The FormData instance that **forEach** is being applied to\n  - **{unknown}** [thisArg = null] – Value to use as **this** context when executing the given **callback**\n\n##### `keys() -\u003e {Generator\u003cstring\u003e}`\n\nReturns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.\nEach key is a `string`.\n\n##### `values() -\u003e {Generator\u003cFormDataValue\u003e}`\n\nReturns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.\nEach value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).\n\n##### `entries() -\u003e {Generator\u003c[string, FormDataValue]\u003e}`\n\nReturns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through key/value pairs contained in this `FormData` object.\nThe key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).\n\n##### `[Symbol.iterator]() -\u003e {Generator\u003c[string, FormDataValue]\u003e}`\n\nAn alias for [`FormData#entries()`](#entries---iterator)\n\n### `class Blob`\n\nThe `Blob` object represents a blob, which is a file-like object of immutable, raw data;\nthey can be read as text or binary data, or converted into a ReadableStream\nso its methods can be used for processing the data.\n\n##### `constructor(blobParts[, options]) -\u003e {Blob}`\n\nCreates a new `Blob` instance. The `Blob` constructor accepts following arguments:\n\n  - **{(ArrayBufferLike | ArrayBufferView | File | Blob | string)[]}** blobParts – An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob);\n  - **{object}** [options = {}] - An options object containing optional attributes for the file. Available options are as follows;\n  - **{string}** [options.type = \"\"] - Returns the media type ([`MIME`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types)) of the blob represented by a `Blob` object.\n\n#### Instance properties\n\n##### `type -\u003e {string}`\n\nReturns the [`MIME type`](https://developer.mozilla.org/en-US/docs/Glossary/MIME_type) of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).\n\n##### `size -\u003e {number}`\n\nReturns the size of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in bytes.\n\n#### Instance methods\n\n##### `slice([start, end, contentType]) -\u003e {Blob}`\n\nCreates and returns a new [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object which contains data from a subset of the blob on which it's called.\n\n- **{number}** [start = 0] An index into the `Blob` indicating the first byte to include in the new `Blob`. If you specify a negative value, it's treated as an offset from the end of the `Blob` toward the beginning. For example, -10 would be the 10th from last byte in the `Blob`. The default value is 0. If you specify a value for start that is larger than the size of the source `Blob`, the returned `Blob` has size 0 and contains no data.\n\n- **{number}** [end = `blob`.size] An index into the `Blob` indicating the first byte that will *not* be included in the new `Blob` (i.e. the byte exactly at this index is not included). If you specify a negative value, it's treated as an offset from the end of the `Blob` toward the beginning. For example, -10 would be the 10th from last byte in the `Blob`. The default value is size.\n\n- **{string}** [contentType = \"\"] The content type to assign to the new ``Blob``; this will be the value of its type property. The default value is an empty string.\n\n##### `stream() -\u003e {ReadableStream\u003cUint8Array\u003e}`\n\nReturns a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) which upon reading returns the data contained within the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).\n\n##### `arrayBuffer() -\u003e {Promise\u003cArrayBuffer\u003e}`\n\nReturns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with the contents of the blob as binary data contained in an [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).\n\n##### `text() -\u003e {Promise\u003cstring\u003e}`\n\nReturns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with a string containing the contents of the blob, interpreted as UTF-8.\n\n### `class File extends Blob`\n\nThe `File` class provides information about files. The `File` class inherits `Blob`.\n\n##### `constructor(fileBits, filename[, options]) -\u003e {File}`\n\nCreates a new `File` instance. The `File` constructor accepts following arguments:\n\n  - **{(ArrayBufferLike | ArrayBufferView | File | Blob | string)[]}** fileBits – An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File);\n  - **{string}** filename – Representing the file name.\n  - **{object}** [options = {}] - An options object containing optional attributes for the file. Available options are as follows;\n  - **{number}** [options.lastModified = Date.now()] – provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date;\n  - **{string}** [options.type = \"\"] - Returns the media type ([`MIME`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types)) of the file represented by a `File` object.\n\n### `fileFromPath(path[, filename, options]) -\u003e {Promise\u003cFile\u003e}`\n\nAvailable from `formdata-node/file-from-path` subpath.\n\nCreates a `File` referencing the one on a disk by given path.\n\n  - **{string}** path - Path to a file\n  - **{string}** [filename] - Optional name of the file. Will be passed as the second argument in `File` constructor. If not presented, the name will be taken from the file's path.\n  - **{object}** [options = {}] - Additional `File` options, except for `lastModified`.\n  - **{string}** [options.type = \"\"] - Returns the media type ([`MIME`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types)) of the file represented by a `File` object.\n\n### `fileFromPathSync(path[, filename, options]) -\u003e {File}`\n\nAvailable from `formdata-node/file-from-path` subpath.\n\nCreates a `File` referencing the one on a disk by given path. Synchronous version of the `fileFromPath`.\n  - **{string}** path - Path to a file\n  - **{string}** [filename] - Optional name of the file. Will be passed as the second argument in `File` constructor. If not presented, the name will be taken from the file's path.\n  - **{object}** [options = {}] - Additional `File` options, except for `lastModified`.\n  - **{string}** [options.type = \"\"] - Returns the media type ([`MIME`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types)) of the file represented by a `File` object.\n\n### `isFile(value) -\u003e {boolean}`\n\nAvailable from `formdata-node/file-from-path` subpath.\n\nChecks if given value is a File, Blob or file-look-a-like object.\n\n  - **{unknown}** value - A value to test\n\n## Related links\n\n- [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) documentation on MDN\n- [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) documentation on MDN\n- [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) documentation on MDN\n- [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue) documentation on MDN.\n- [`formdata-polyfill`](https://github.com/jimmywarting/FormData) HTML5 `FormData` for Browsers \u0026 NodeJS.\n- [`node-fetch`](https://github.com/node-fetch/node-fetch) a light-weight module that brings the Fetch API to Node.js\n- [`fetch-blob`](https://github.com/node-fetch/fetch-blob) a Blob implementation on node.js, originally from `node-fetch`.\n- [`form-data-encoder`](https://github.com/octet-stream/form-data-encoder) spec-compliant `multipart/form-data` encoder implementation.\n- [`then-busboy`](https://github.com/octet-stream/then-busboy) a promise-based wrapper around Busboy. Process multipart/form-data content and returns it as a single object. Will be helpful to handle your data on the server-side applications.\n- [`@octetstream/object-to-form-data`](https://github.com/octet-stream/object-to-form-data) converts JavaScript object to FormData.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctet-stream%2Fform-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctet-stream%2Fform-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctet-stream%2Fform-data/lists"}