# Read/Write Files to Cloud Storage

In Burla, `/workspace/shared` is a shared folder connected to your Google Cloud Storage bucket:

* Save a file to `/workspace/shared/...` and it shows up in your bucket.
* Read a file from `/workspace/shared/...` and it is read from your bucket.

## Before you run this

1. Install Burla: `pip install burla`
2. Log in: `burla login`
3. Start a machine in the Burla dashboard.

## Step 1: Write files (saves to GCS)

```python
from pathlib import Path
from burla import remote_parallel_map

def write_text_file(file_path, text):
    Path(file_path).write_text(text)
    return file_path

files_to_write = [
    ("/workspace/shared/hello.txt", "hello\n"),
    ("/workspace/shared/goodbye.txt", "goodbye\n"),
]

remote_parallel_map(write_text_file, files_to_write)
```

In the Burla dashboard → **Filesystem**, you should see:

* `/workspace/shared/hello.txt`
* `/workspace/shared/goodbye.txt`

<figure><img src="/files/K2GrqSHL3tqn3K7frtw8" alt=""><figcaption></figcaption></figure>

## Step 2: Read files back (comes from GCS)

```python
from pathlib import Path
from burla import remote_parallel_map

def read_text_file(file_path):
    return {"path": file_path, "text": Path(file_path).read_text()}

files_to_read = [
    "/workspace/shared/hello.txt",
    "/workspace/shared/goodbye.txt",
]

results = remote_parallel_map(read_text_file, files_to_read)
print(results)
```

You should see a list with the file paths and their text (the words `hello` and `goodbye`):

```bash
[{'path': '/workspace/shared/hello.txt', 'text': 'hello'},
 {'path': '/workspace/shared/goodbye.txt', 'text': 'goodbye'}]
```

Congrats! You just wrote to, and read from, a Google Cloud Storage bucket, in parallel, using Burla.

Reach out to **<jake@burla.dev>** if you have any questions!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.burla.dev/all-examples/basic-examples/read-and-write-gcs-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
