nazartopproger
v1.0.1
Published
bigdick
Downloads
3
Readme
File Uploader Package
This is a simple Node.js package for handling file uploads using Express and Multer.
Installation
Install the package via npm:
npm install express multer file-uploader
Usage
- Require the
file-uploader
package in your Node.js application:
const express = require('express');
const fileUploader = require('file-uploader');
- Initialize an Express app:
const app = express();
- Define a route for handling file uploads:
app.post('/upload', fileUploader.upload.single('file'), (req, res) => {
res.json({ message: 'File uploaded successfully', filename: req.file.filename });
});
- Start the server:
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
Configuration
You can configure the destination directory and filename format for uploaded files by modifying the storage
object in the index.js
file.
License
This project is licensed under the MIT License - see the LICENSE file for details.