update router getType
All checks were successful
Deploy to Production / deploy (push) Successful in 21s
All checks were successful
Deploy to Production / deploy (push) Successful in 21s
This commit is contained in:
119
routes/uploadRoutes.js
Normal file
119
routes/uploadRoutes.js
Normal file
@@ -0,0 +1,119 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const uploadController = require('../controllers/uploadController');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Upload
|
||||
* description: File upload management
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/upload/single:
|
||||
* post:
|
||||
* summary: Upload single file
|
||||
* tags: [Upload]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* multipart/form-data:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* file:
|
||||
* type: string
|
||||
* format: binary
|
||||
* description: File to upload (images → public/images, audio/video → public/media, others → public/files)
|
||||
* responses:
|
||||
* 201:
|
||||
* description: File uploaded successfully
|
||||
* 400:
|
||||
* description: No file uploaded or upload error
|
||||
* 500:
|
||||
* description: Server error
|
||||
*/
|
||||
router.post('/single', (req, res, next) => {
|
||||
uploadController.uploadSingle(req, res, next);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/upload/multiple:
|
||||
* post:
|
||||
* summary: Upload multiple files (max 10)
|
||||
* tags: [Upload]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* multipart/form-data:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* files:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
* format: binary
|
||||
* description: Files to upload (max 10 files)
|
||||
* responses:
|
||||
* 201:
|
||||
* description: Files uploaded successfully
|
||||
* 400:
|
||||
* description: No files uploaded or upload error
|
||||
* 500:
|
||||
* description: Server error
|
||||
*/
|
||||
router.post('/multiple', (req, res, next) => {
|
||||
uploadController.uploadMultiple(req, res, next);
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/upload/file:
|
||||
* delete:
|
||||
* summary: Delete uploaded file
|
||||
* tags: [Upload]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - filepath
|
||||
* properties:
|
||||
* filepath:
|
||||
* type: string
|
||||
* example: "public/images/example-1234567890.jpg"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: File deleted successfully
|
||||
* 404:
|
||||
* description: File not found
|
||||
*/
|
||||
router.delete('/file', uploadController.deleteFile);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/upload/info:
|
||||
* get:
|
||||
* summary: Get file information
|
||||
* tags: [Upload]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: filepath
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Path to the file
|
||||
* responses:
|
||||
* 200:
|
||||
* description: File info retrieved successfully
|
||||
* 404:
|
||||
* description: File not found
|
||||
*/
|
||||
router.get('/info', uploadController.getFileInfo);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user