Skip to content

File Management

Interfaces for managing uploaded files.

Get File List

Get all uploaded files.

Interface Information

  • Endpoint: GET /api/admin/files
  • Authentication: Required (admin permission)

Query Parameters

ParameterTypeRequiredDescription
pagenumberNoPage number, default 1
limitnumberNoItems per page, default 20
typestringNoFile type filter: image/document/other

Upload File

Upload single or multiple files.

Interface Information

  • Endpoint: POST /api/admin/files/upload
  • Authentication: Required (admin permission)
  • Content-Type: multipart/form-data

Request Parameters

ParameterTypeRequiredDescription
filesfileYesFile (supports multiple)

Request Example

bash
curl -X POST http://localhost:3000/api/admin/files/upload \
  -H "Authorization: Bearer your-jwt-token" \
  -F "files=@image1.jpg" \
  -F "files=@document.pdf"

Response Example

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "filename": "image1.jpg",
      "url": "https://example.com/uploads/image1.jpg",
      "size": 102400,
      "type": "image"
    }
  ]
}

Delete File

Delete specified file.

Interface Information

  • Endpoint: DELETE /api/admin/files/:id
  • Authentication: Required (admin permission)

Error Responses

HTTP Status CodeDescription
401Not logged in or token invalid
403Insufficient permission (non-admin)
404File does not exist
413File too large
500Server error

File Limits

  • Single file maximum 10MB
  • Supported image formats: jpg, jpeg, png, gif, webp
  • Supported document formats: pdf, doc, docx, xls, xlsx