https://github.com/oelin/node-add-file
Elegantly add files to FormData objects 📋.
https://github.com/oelin/node-add-file
file form form-data http io
Last synced: about 2 months ago
JSON representation
Elegantly add files to FormData objects 📋.
- Host: GitHub
- URL: https://github.com/oelin/node-add-file
- Owner: oelin
- License: mit
- Created: 2023-02-08T09:49:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-08T10:47:02.000Z (over 3 years ago)
- Last Synced: 2025-12-28T16:22:01.407Z (6 months ago)
- Topics: file, form, form-data, http, io
- Language: JavaScript
- Homepage: https://npmjs.com/node-add-file
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-add-file
Elegantly add files to `FormData` objects 📋.
## Installation
```sh
npm i node-add-file
```
## Usage
Create a "file adder".
```js
import addFile from 'node-add-file'
const addReadme = addFile('./README.md')
```
Use the adder to add `README.md` to one or more `FormData` objects.
```js
addReadme(formA) // Adds README.md to formA.
addReadme(formB) // Adds README.md to formB.
addReadme(formA, name = 'README') // Adds README.md to formA with name `README`.
addReadme(formA, name = 'README', type = 'text/markdown') // Also sets the mime type to `text/markdown`
```
The default name is `file` and the default mime type is `text/plain`.
## API
### addFile(filename)
Returns a file adder which can be used to add the file one or more `FormData` objects.