> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing files

> Browse, read, create, move and delete files inside your application.

```go theme={null}
client := rest.NewClient(os.Getenv("SQUARECLOUD_API_KEY"))
defer client.Close()

api := rest.New(client)
```

## Listing files in a directory

`api.GetApplicationFiles(appID, path)` returns the entries of a directory as a `[]squarecloud.FileInfo`. An empty path lists the application root.

```go theme={null}
entries, err := api.GetApplicationFiles("abc123def456abc123def456", "")
if err != nil {
	panic(err)
}

for _, entry := range entries {
	fmt.Println(entry.Type, entry.Name, entry.Size, entry.LastModified)
}
```

| Field          | Type     | Description                                |
| -------------- | -------- | ------------------------------------------ |
| `Type`         | `string` | `"file"` or `"directory"`                  |
| `Name`         | `string` | Entry name                                 |
| `Size`         | `int`    | Size in bytes — always `0` for directories |
| `LastModified` | `int64`  | Last modification in Unix milliseconds     |

## Reading a file

`api.ReadApplicationFile(appID, path)` returns a `squarecloud.FileContent` with the file bytes.

```go theme={null}
content, err := api.ReadApplicationFile("abc123def456abc123def456", "main.go")
if err != nil {
	panic(err)
}

fmt.Println(string(content.Data))
```

<Note>
  The API returns the content as a Node.js-style Buffer object (`{"type": "Buffer", "data": [...]}`). The SDK decodes it for you — `content.Data` is a plain `[]byte` (the `ByteArray` type), ready to use.
</Note>

## Creating or overwriting a file

`api.PutApplicationFile(appID, path, content)` writes `content` at `path`, creating the file if it does not exist or overwriting it if it does. It returns a `squarecloud.FileWritten`.

```go theme={null}
written, err := api.PutApplicationFile(
	"abc123def456abc123def456",
	"config/settings.json",
	[]byte(`{"debug": false}`),
)
if err != nil {
	panic(err)
}

fmt.Println(written.Written) // true
```

<Note>
  The content is sent to the API as a UTF-8 string — binary file uploads are not supported yet. To ship binary files, use a [commit](/en/sdks/go/commit_and_upload) instead.
</Note>

## Moving or renaming a file

`api.MoveApplicationFile(appID, path, to)` moves or renames a file.

```go theme={null}
err := api.MoveApplicationFile("abc123def456abc123def456", "main.go", "src/main.go")
if err != nil {
	panic(err)
}
```

## Deleting a file or directory

<Warning>
  Deleting a directory removes everything inside it. There is no way to recover deleted files unless you have a [snapshot](/en/sdks/go/snapshots).
</Warning>

```go theme={null}
err := api.DeleteApplicationFile("abc123def456abc123def456", "src/old.go")
if err != nil {
	panic(err)
}
```
