New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@blubox/multer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blubox/multer

Blubox multer

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Multer Middleware

A middleware for handling file uploads in your web server.

Installation

npm install @blubox/multer

Usage


const multer, { Options, File, Storage } = require('@blubox/multer')
const { Controller } = require('blubox')

// Define storage options
const storageOptions = {
  destination: './uploads',
  filename: (ctx, file) => `${Date.now()}-${file.originalname}`
};

// Initialize storage
const storage = new Storage(storageOptions);

// Define multer options
const multerOptions: Options = {
  fields: ['image', 'document'],
  extnames: ['.jpg', '.png', '.pdf'],
  storage: storage
};

// Create the multer middleware
const multerMiddleware = multer(multerOptions);

const controller = new Controller()
controller.use(multerMiddleware)

Options

fields: Array of field names or objects with name and maxCount properties. extnames: Array of allowed file extensions. storage: Instance of the Storage class.

Storage Class

The Storage class provides methods for creating filenames, destinations, and paths based on user-defined functions or strings.

const storage = new Storage({
	destination: (ctx, file) => './uploads',
	filename: (ctx, file) => `${Date.now()}-${file.originalname}`,
})

License

MIT

Keywords

multer

FAQs

Package last updated on 12 Dec 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