Socket
Book a DemoInstallSign in
Socket

node-add-file

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-add-file

Elegantly add files to FormData objects đź“‹.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

node-add-file

Elegantly add files to FormData objects đź“‹.

Installation

npm i node-add-file

Usage

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.

Keywords

file

FAQs

Package last updated on 08 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts