Skip to content

File Manager & Git

Overview

The built-in file manager provides browser-based access to website files with syntax-highlighted editing, upload/download, archive management, and integrated Git operations.

All file manager operations require the websites_management permission. The username query parameter specifies which website's files to access.

Listing Files

GET /api/filemanager?username=example&path=/

Response:

{
  "data": [
    {
      "name": "public_html",
      "type": "dir",
      "size": 4096,
      "permissions": "0755",
      "modified": "2024-01-15T10:00:00Z"
    }
  ]
}

Reading a File

GET /api/filemanager/read?username=example&path=/public_html/index.php

Writing a File

POST /api/filemanager/write?username=example
{
  "path": "/public_html/index.php",
  "content": "<?php echo 'Hello'; ?>"
}

Uploading Files

POST /api/filemanager/upload?username=example&path=/public_html/
Content-Type: multipart/form-data

# Form field: file (binary)

Downloading a File

GET /api/filemanager/download?username=example&path=/public_html/archive.zip

Creating a Directory

POST /api/filemanager/mkdir
{
  "username": "example",
  "path": "/public_html/new-dir"
}

Deleting Files/Directories

POST /api/filemanager/delete
{
  "username": "example",
  "paths": ["/public_html/old-file.php", "/public_html/temp/"]
}

Renaming / Moving

# Rename
POST /api/filemanager/rename
{
  "username": "example",
  "old_path": "/public_html/old.php",
  "new_path": "/public_html/new.php"
}

# Move (multiple files)
POST /api/filemanager/move
{
  "username": "example",
  "paths": ["/public_html/file1.php"],
  "destination": "/public_html/backup/"
}

Copying Files

POST /api/filemanager/copy
{
  "username": "example",
  "paths": ["/public_html/config.php"],
  "destination": "/public_html/backup/"
}

Permissions (chmod)

POST /api/filemanager/chmod
{
  "username": "example",
  "path": "/public_html/",
  "mode": "0755",
  "recursive": true
}

Archive: Compress & Extract

# Compress to zip/tar.gz
POST /api/filemanager/compress
{
  "username": "example",
  "paths": ["/public_html/"],
  "destination": "/backups/site.tar.gz",
  "format": "tar.gz"
}

# Extract archive
POST /api/filemanager/extract
{
  "username": "example",
  "path": "/backups/site.tar.gz",
  "destination": "/public_html/"
}

Downloading from URL

POST /api/filemanager/download-url
{
  "username": "example",
  "url": "https://example.com/file.zip",
  "path": "/public_html/"
}

File History (Versioning)

StarkOne tracks changes to files in the file manager:

# Get history for a file
GET /api/filemanager/history?username=example&path=/public_html/index.php

# Get all history
GET /api/filemanager/history/all?username=example

# Download historical version
GET /api/filemanager/history/download?username=example&path=...&revision=...

# View historical content
GET /api/filemanager/history/content?username=example&path=...&revision=...

# Restore a previous version
POST /api/filemanager/history/restore
{
  "username": "example",
  "path": "/public_html/index.php",
  "revision": "abc123"
}

# Clear history
POST /api/filemanager/history/clear
{ "username": "example" }

Locking Files

Prevent concurrent edits:

POST /api/filemanager/lock
{ "username": "example", "path": "/public_html/index.php" }

POST /api/filemanager/unlock
{ "username": "example", "path": "/public_html/index.php" }

Searching Files

GET /api/filemanager/search?username=example&query=function+foo&path=/public_html

Or via website endpoint:

POST /api/webapps/:id/files/search
{ "query": "function foo", "path": "/public_html" }

Git Integration

The file manager includes full Git support per website.

Status

GET /api/filemanager/git?username=example&path=/public_html

Returns current branch, staged/unstaged changes, untracked files.

Diff

GET /api/filemanager/git/diff?username=example&path=/public_html&file=index.php

Pull

POST /api/filemanager/git/pull
{ "username": "example", "path": "/public_html" }

Commit

POST /api/filemanager/git/commit
{
  "username": "example",
  "path": "/public_html",
  "message": "Fix header layout",
  "files": ["index.php", "style.css"]   # optional, commits all if omitted
}

Push

POST /api/filemanager/git/push
{
  "username": "example",
  "path": "/public_html"
}

Clone a Repository

POST /api/filemanager/git/clone
{
  "username": "example",
  "path": "/public_html",
  "url": "https://github.com/org/repo.git",
  "branch": "main"
}

Init Repository

POST /api/filemanager/git/init
{ "username": "example", "path": "/public_html" }

Add Remote

POST /api/filemanager/git/remote
{
  "username": "example",
  "path": "/public_html",
  "url": "https://github.com/org/repo.git",
  "name": "origin"
}

Commit Log

GET /api/filemanager/git/log?username=example&path=/public_html&limit=20

Show Commit

GET /api/filemanager/git/show?username=example&path=/public_html&hash=abc123

Revert Commit

POST /api/filemanager/git/revert
{
  "username": "example",
  "path": "/public_html",
  "hash": "abc123"
}