File Base URL

http://localhost:8000/api/file

All routes below are prefixed with this base URL.

1️⃣ Upload File

POST /upload 🔒 JWT Required

Description: Upload a single file to the server. The file is stored locally and metadata is saved in the database.

Authentication

Authorization: Bearer <your_token>

Headers

Content-Type: multipart/form-data

Request Body (form-data)

file → Required (File)
Accepted types: images, pdf, etc. (based on backend config)

cURL Example

curl -X POST http://localhost:8000/api/file/upload \ -H "Authorization: Bearer YOUR_TOKEN" \ -F "file=@file.jpg"

Success Response (200)

{ "message": "File uploaded successfully", "data": { "fileId": "uuid-generated-id", "fileUrl": "/upload/file/filename.jpg", "size": 204800, "type": "image/jpeg" } }

Error Responses

400 Bad Request { "error": "No file uploaded" } 401 Unauthorized { "error": "Invalid or missing token" } 500 Internal Server Error { "error": "Internal Server Error" }

Notes