Skip to main content

Endpoint

POST /api/servers/:server/files/compress

Authentication

Requires Bearer token authentication via the Authorization header.

Path Parameters

server
string
required
The UUID of the server

Request Body

root
string
required
The root directory for compression operations (all paths are relative to this)
files
string[]
required
Array of file/directory paths to include in the archive (relative to root)

Response

Returns a JSON object with the created archive information.
file
object
Information about the created archive file

Example Request

curl -X POST "https://wings.example.com/api/servers/d3aac109-f0fc-4674-b5bc-199bb50e6b88/files/compress" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "root": "/",
    "files": ["world", "world_nether", "world_the_end"]
  }'

Example Response

{
  "file": {
    "name": "archive-2024-01-15-143022.tar.gz",
    "mode": "-rw-r--r--",
    "mode_bits": "0644",
    "size": 52428800,
    "is_file": true,
    "is_symlink": false,
    "mimetype": "application/gzip",
    "created_at": "2024-01-15T14:30:22Z",
    "modified_at": "2024-01-15T14:30:22Z"
  }
}

Behavior

  • Creates a gzip-compressed tar archive (.tar.gz)
  • Archive is created in the specified root directory
  • Filename format: archive-YYYY-MM-DD-HHMMSS.tar.gz
  • Both files and directories can be compressed
  • Directories are archived recursively
  • Preserves file permissions and timestamps
  • Symlinks are followed and their targets are archived
  • Path traversal is prevented
The compression operation runs asynchronously. The response is returned immediately with the expected archive information, but the actual compression may take some time for large datasets.

Error Responses

Missing or invalid Bearer token
Server does not exist or source files not found
Failed to create archive (disk full, permission error, etc.)

Use Cases

  • Create backups of world files
  • Archive old logs
  • Package plugins for transfer
  • Create downloadable server snapshots
  • Prepare files for export

Source Reference

Implementation: router/router_server_files.go (postServerCompressFiles function)

Build docs developers (and LLMs) love