Skip to content

Express.js middleware to clean up uploaded files after multer

License

Notifications You must be signed in to change notification settings

myrotvorets/clean-up-after-multer

Repository files navigation

clean-up-after-multer

Quality Gate Status Build and Test

Express.js middleware to clean up uploaded files after multer

Usage

import express from 'express';
import { cleanUploadedFilesMiddleware } from '@myrotvorets/clean-up-after-multer'


const app = express();
app.use(/* your middlewares here */);
app.use(cleanUploadedFilesMiddleware());

Make sure to call next() from your middlewares.

cleanUploadedFilesMiddleware() accepts an argument of type (path: string) => Promise<unknown> to specify the custom unlink() function (in case you want to log unlink failures etc).