Skip to main content
Each snippet below runs on its own inside this program: paste one at a time into main and run goimports (see Running the examples).

Accepted inputs

Apps.Create and Apps.Commit take any io.Reader and stream it as multipart/form-data, never loading it into memory: Uploads are limited to 100 MB. A larger file fails locally with FILE_TOO_LARGE (status 0): before anything is sent when the size is known, otherwise as soon as the stream passes 100 MB. Uploads have no default deadline: cancel them with ctx.

Creating an application

Apps.Create(ctx, zip) deploys a .zip that contains a squarecloud.app configuration file at its root.

Committing to an application

Apps.Commit(ctx, appID, r, path, filename) uploads a file into an existing app:
  • A .zip is unpacked at path ("" for the app root).
  • Any other file lands at path/<filename>.
The filename is filename, else the reader’s own name (the base name of an *os.File), else commit.zip. Pass "" to use the default.
A commit does not restart the app. Call Apps.Restart to apply it.

Cancelling an upload

A canceled upload returns an *APIError (NETWORK_ERROR when ctx was canceled, TIMEOUT when its deadline passed) that unwraps to context.Canceled or context.DeadlineExceeded.

Errors

Opening the file is up to your code, so an os.Open error never reaches the SDK. A nil reader returns a plain error, not an *APIError. See Errors for the full list.

Next steps

Managing files

List, read, write, move and delete app files.

Upload API reference

The REST endpoints behind these methods.

Upload from the CLI

The same actions from the terminal.