Skip to main content
The file manager lives on c.Apps.Files. Every method takes ctx and the app id first, then a path inside the app. Paths are at most 256 characters. Each snippet below runs on its own inside this program: paste one at a time into main and run goimports (see Running the examples).

Listing a directory

Files.List(ctx, appID, path) lists a directory ("" for the app root).
A directory that does not exist is 404 FILE_NOT_FOUND. A path the file manager does not expose is 403 BLOCKED_PATH.

Reading a file

Files.Read(ctx, appID, path) returns the file’s bytes as a []byte. Files are limited to 10 MB: a larger one is 413 FILE_TOO_LARGE.

Writing a file

Files.Write(ctx, appID, path, content) creates or overwrites a file. content is a []byte:
  • It is always sent as base64, so text and binary content round-trip byte for byte. To write a string, pass []byte(s).
  • Empty content (nil or an empty slice) creates an empty file.
Content over 10 MB fails locally with FILE_TOO_LARGE (status 0) before anything is sent. Content over 1 MiB gets no default deadline, like an upload: bound or cancel it with ctx. For larger files, use Apps.Commit.
Writing does not restart the app. Call Apps.Restart to apply the change.

Moving or renaming a file

Deleting a file

Errors

See Errors for the codes every call can return.

Next steps

Environment variables

Read and change the variables of an app.

File manager API reference

The REST endpoints behind these methods.

Manage files from the CLI

The same actions from the terminal.