{"_id":"@abdurrahmanabid/multi-file-upload","_rev":"3-3787869798920b631d72f28c3acf3615","name":"@abdurrahmanabid/multi-file-upload","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@abdurrahmanabid/multi-file-upload","version":"1.0.0","keywords":["all-file-upload","file","image","pdf-upload","image-upload","upload-files"],"author":{"name":"\"Abdur Rahman Abid\""},"license":"ISC","_id":"@abdurrahmanabid/multi-file-upload@1.0.0","maintainers":[{"name":"abdurrahmanabid","email":"abdurrahmanabid33@gmail.com"}],"dist":{"shasum":"6ac1c34eef27ecf46d6cd217b2184db5c190fdce","tarball":"https://registry.npmjs.org/@abdurrahmanabid/multi-file-upload/-/multi-file-upload-1.0.0.tgz","fileCount":3,"integrity":"sha512-2Xv6CBgOaZg3A8j9DMQCl6RZWHc3LCfAHzsP/2sQx/rdlsV62xY5sdz9QpN0YmAXeL6DaurDIWCTrkBewqcdvg==","signatures":[{"sig":"MEYCIQCr4tmvfM2dgEI71aO/y9F7oxsI98Z9ELdkEqjzctb2cAIhAIHaz7fmWWj+ROvHWJ1qDQ6m/y+mq2PzEOkiwYgLocLm","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5998},"main":"index.js","type":"commonjs","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"abdurrahmanabid","email":"abdurrahmanabid33@gmail.com"},"_npmVersion":"11.1.0","description":"\"A simple middleware for handling single and multiple file uploads with customizable file types and directories.\"","directories":{},"_nodeVersion":"20.17.0","dependencies":{"multer":"^1.4.5-lts.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/multi-file-upload_1.0.0_1738690315360_0.19656087696500646","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@abdurrahmanabid/multi-file-upload","version":"1.0.1","keywords":["all-file-upload","file","image","pdf-upload","image-upload","upload-files"],"author":{"name":"\"Abdur Rahman Abid\""},"license":"ISC","_id":"@abdurrahmanabid/multi-file-upload@1.0.1","maintainers":[{"name":"abdurrahmanabid","email":"abdurrahmanabid33@gmail.com"}],"dist":{"shasum":"bcb022ddc18d03febc2dc08ba42646322f91a9b0","tarball":"https://registry.npmjs.org/@abdurrahmanabid/multi-file-upload/-/multi-file-upload-1.0.1.tgz","fileCount":3,"integrity":"sha512-Xg1tJPNZgYqlsJ2uJRhu44YI37Gd5txutF4UBNsXq1CyiaW+q3B3A3MNlikFRK7qKEvlK4fqWo7WytK0yeuEng==","signatures":[{"sig":"MEUCIQDtebNT96CnUiQOcKl2ZIXRVUAAJ/zIRjDwQ5CJhZzlBAIgDOnPAGi5tS9KZem9cN+nbcl+BIz9QU7QZtrG2KKQ3Sc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6398},"main":"index.js","type":"commonjs","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"abdurrahmanabid","email":"abdurrahmanabid33@gmail.com"},"_npmVersion":"11.1.0","description":"\"A simple middleware for handling single and multiple file uploads with customizable file types and directories.\"","directories":{},"_nodeVersion":"20.17.0","dependencies":{"multer":"^1.4.5-lts.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/multi-file-upload_1.0.1_1739948833239_0.5822614879264656","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@abdurrahmanabid/multi-file-upload","version":"1.0.2","description":"\"A simple middleware for handling single and multiple file uploads with customizable file types and directories.\"","keywords":["all-file-upload","file","image","pdf-upload","image-upload","upload-files"],"license":"ISC","author":{"name":"\"Abdur Rahman Abid\""},"main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","dependencies":{"multer":"^1.4.5-lts.1","tslib":"^2.8.1"},"devDependencies":{"@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-typescript":"^11.1.5","@types/express":"^5.0.3","@types/multer":"^2.0.0","@types/node":"^24.1.0","rollup":"^4.16.4","typescript":"^5.4.5"},"scripts":{"build:tsc":"tsc","build:rollup":"rollup -c","build":"npm run build:tsc && npm run build:rollup","test":"echo \"Error: no test specified\" && exit 1"},"_id":"@abdurrahmanabid/multi-file-upload@1.0.2","gitHead":"f8e0a32485b6726ee8900e1e6cfe3a3b56924429","_nodeVersion":"22.16.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-rhd1p65uyuRr8AM6NgF8V8Ld1F9hbHARhNwWSQCf+QNp6ocTVnHRPEPUnyiTE6xQG7AyYlLlN141R4dKlkTeAw==","shasum":"e359b04e6f8ba8d3e95adac792d10ccb6aaab053","tarball":"https://registry.npmjs.org/@abdurrahmanabid/multi-file-upload/-/multi-file-upload-1.0.2.tgz","fileCount":11,"unpackedSize":18062,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC383d1vsnhQXeooHPOcBoSmYUivI4x9HDWE3lbABBMLAIhAKNCVllR1+ZTxgrbihdpwI0EyjHjHHMti0s0TGriMxDY"}]},"_npmUser":{"name":"abdurrahmanabid","email":"abdurrahmanabid33@gmail.com"},"directories":{},"maintainers":[{"name":"abdurrahmanabid","email":"abdurrahmanabid33@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/multi-file-upload_1.0.2_1753213706555_0.6920722705113951"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-04T17:31:55.267Z","modified":"2025-07-22T19:48:27.003Z","1.0.0":"2025-02-04T17:31:55.521Z","1.0.1":"2025-02-19T07:07:13.451Z","1.0.2":"2025-07-22T19:48:26.764Z"},"author":{"name":"\"Abdur Rahman Abid\""},"license":"ISC","keywords":["all-file-upload","file","image","pdf-upload","image-upload","upload-files"],"description":"\"A simple middleware for handling single and multiple file uploads with customizable file types and directories.\"","maintainers":[{"name":"abdurrahmanabid","email":"abdurrahmanabid33@gmail.com"}],"readme":"\n# @abdurrahmanabid/multi-file-upload\n\nA simple yet powerful Express.js middleware for handling **single and multiple** file uploads using Multer.  \nThis package supports **custom file types, directory selection, error handling, and more**.\n\n---\n\n## 🚀 Features\n✅ **Single & Multiple File Uploads**  \n✅ **Custom Upload Directories**  \n✅ **File Type Restrictions**  \n✅ **Multer-based Efficient Storage**  \n✅ **Comprehensive Error Handling**  \n\n---\n\n## 📌 Installation\nBefore using this package, ensure you have **Node.js** and **Express.js** installed.\n\n### **1️⃣ Install the Package**\nRun the following command:\n```bash\nnpm install @abdurrahmanabid/multi-file-upload\n```\n\n> **Note:** `express` must be installed as it's a peer dependency. If not installed, run:\n```bash\nnpm install express\n```\n\n### **2️⃣ Import the Package**\nIn your Express.js app:\n```javascript\nconst uploadHandler = require(\"@abdurrahmanabid/multi-file-upload\");\n```\n\n---\n\n## 🎯 **Usage Examples**\n\n### **1️⃣ Basic Single File Upload**\n```javascript\nconst express = require(\"express\");\nconst uploadHandler = require(\"@abdurrahmanabid/multi-file-upload\");\n\nconst app = express();\n\napp.post(\"/upload\", uploadHandler(\"single\"));\n\napp.listen(3000, () => console.log(\"Server running on port 3000\"));\n```\n✅ **Now, you can upload a single file using Postman!**\n\n---\n\n### **2️⃣ Upload Multiple Files**\n```javascript\napp.post(\"/upload-multiple\", uploadHandler(\"multiple\"));\n```\n- Upload multiple files via **Postman** using `form-data` with key **file**.\n\n---\n\n### **3️⃣ Restrict File Types (Only Images)**\n```javascript\napp.post(\"/upload-images\", uploadHandler(\"single\", [\"image/png\", \"image/jpeg\"]));\n```\n- This will **only** allow `.png` and `.jpg` files.\n\n---\n\n### **4️⃣ Upload to a Custom Directory**\n```javascript\napp.post(\"/upload-avatar\", uploadHandler(\"single\", [], \"uploads/avatars\"));\n```\n- Files will be stored in **uploads/avatars/** instead of the default **uploads/**.\n\n---\n\n## 🛠 **Advanced Configuration**\n| Parameter       | Type     | Description                                       | Default      |\n|---------------|---------|--------------------------------------------------|-------------|\n| `uploadType`  | string  | `\"single\"` or `\"multiple\"`                        | `\"single\"`  |\n| `acceptedTypes` | array  | Allowed file types (e.g., `[\"image/png\"]`)       | `[]` (All)  |\n| `directory`   | string  | Directory where files will be stored             | `\"uploads/\"` |\n\nExample:\n```javascript\napp.post(\"/custom-upload\", uploadHandler(\"multiple\", [\"image/png\", \"image/jpeg\"], \"custom_dir\"));\n```\n\n---\n\n## **📜 How to Use in Postman**\n1. Open **Postman**.\n2. Select **POST** method.\n3. Enter the API endpoint, e.g., `http://localhost:3000/upload`.\n4. Go to the **Body** tab ➝ Select **form-data**.\n5. Use **Key**:\n   - `\"file\"` for **single** or **multiple** uploads.\n6. Click **Select File**, upload a file.\n7. Click **Send**.\n\n---\n\n## ❌ **Common Issues & Solutions**\n| Issue | Cause | Solution |\n|-------|------|-----------|\n| `Cannot find module 'express'` | Express is not installed | Run `npm install express` |\n| `MulterError: Unexpected field` | Incorrect field name in Postman | Use `file` for single & `files` for multiple |\n| `Invalid file type` | Unsupported file format | Pass correct MIME types in `acceptedTypes` |\n","readmeFilename":"README.md"}