Skip to main content

Endpoint

GET /api/servers/:server/files/contents

Authentication

Requires Bearer token authentication via the Authorization header.

Path Parameters

server
string
required
The UUID of the server

Query Parameters

file
string
required
The file path to read (relative to server root)
download
string
If present (any value), the response will include download headers

Response

Returns the raw file contents with appropriate headers.

Response Headers

  • X-Mime-Type: Detected MIME type of the file
  • Content-Length: Size of the file in bytes
  • Content-Disposition: Set to attachment if download parameter is present
  • Content-Type: Set to application/octet-stream for downloads, otherwise the file’s MIME type

Example Request

curl -X GET "https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/contents?file=server.properties" \
  -H "Authorization: Bearer YOUR_TOKEN"

Behavior

  • Leading slashes in the file path are automatically stripped
  • Named pipes cannot be opened (returns 400 error)
  • File size is determined at request time and a limited reader prevents content overflow
  • Path traversal is prevented - files outside the server directory cannot be accessed
If the file is modified while being read, you may receive partial or inconsistent content based on the file size at the time the request started.

Error Responses

File is a named pipe or another unsupported file type
Missing or invalid Bearer token
Server or file does not exist
Failed to read file contents

Use Cases

  • View configuration files
  • Read log files
  • Download world/map files
  • Inspect server data files

Source Reference

Implementation: router/router_server_files.go:30-75

Build docs developers (and LLMs) love