1.0.0 • Published 3 years ago
node-add-file v1.0.0
node-add-file
Elegantly add files to FormData objects 📋.
Installation
npm i node-add-fileUsage
Create a "file adder".
import addFile from 'node-add-file'
const addReadme = addFile('./README.md')Use the adder to add README.md to one or more FormData objects.
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.
1.0.0
3 years ago