Spaces:
Running
Running
Download src/middleware/upload.js from shard-c6/green-guard-api: direct link, hf CLI and curl.
- Browser
- Download file 622 Bytes
-
https://huggingface.co/spaces/shard-c6/green-guard-api/resolve/main/src/middleware/upload.js
- Command line
-
hf download hf://spaces/shard-c6/green-guard-api/src/middleware/upload.js
-
curl -L -o upload.js https://huggingface.co/spaces/shard-c6/green-guard-api/resolve/main/src/middleware/upload.js
622 Bytes
| const multer = require('multer'); | |
| const env = require('../config/env'); | |
| /** | |
| * Multer config — stores files in memory (Buffer) for forwarding to Supabase Storage. | |
| */ | |
| const upload = multer({ | |
| storage: multer.memoryStorage(), | |
| limits: { | |
| fileSize: env.maxFileSizeMb * 1024 * 1024, // default 5MB | |
| }, | |
| fileFilter: (req, file, cb) => { | |
| const allowedMimes = ['image/jpeg', 'image/png', 'image/webp', 'image/gif']; | |
| if (allowedMimes.includes(file.mimetype)) { | |
| cb(null, true); | |
| } else { | |
| cb(new Error('Only JPEG, PNG, WebP, and GIF images are allowed.')); | |
| } | |
| }, | |
| }); | |
| module.exports = upload; | |