# R2 Copy output from remote

In the Float16 project, each project has its own remote storage that automatically stores Python files and output files generated during run or deploy commands. This tutorial will guide you through copying output files from remote storage to your personal Cloudflare R2 storage.

{% hint style="info" %}

* An active Float16 project
* Cloudflare R2 storage credentials
  {% endhint %}

## Step 1 : Prepare Your Script

Create a Python script (e.g., `test_output.py`) that generates an output file

```python
import os

class FileWriter:
    def __init__(self, folder_name="output_files"):
        self.output_dir = folder_name
        os.makedirs(self.output_dir, exist_ok=True)
    
    def get_file_path(self, filename):
        return os.path.join(self.output_dir, filename)
    
    def write_simple_text(self):
        filename = f"output.txt"
        with open(self.get_file_path(filename), 'w', encoding='utf-8') as file:
            file.write('Hi\n')
            file.write('This is Serverless GPU\n')
            file.write('from Float16')
        return filename

def main():
    writer = FileWriter("my_output_files")
    
    print("processing...")
    
    simple_file = writer.write_simple_text()
    print(f"- write {simple_file} successfully")
    
    print(f"\nOutput Path: {os.path.abspath(writer.output_dir)}")

if __name__ == '__main__':
    main()
```

## Step 2 : Run your script

First, start your project and then run the script

```
float16 project start
```

```
float16 run test_output.py
```

you will got successfully response from CLI.

## Step 3 : Check Remote Storage

Check the files in your remote storage

```
float16 storage ls
```

## Step 4 : Copy Output to R2

Use the following command to copy your output to Cloudflare R2

{% code overflow="wrap" %}

```
float16 storage copy-output \
    --path /workspace/output.txt \
    --s3-uri https://40557a5d82224556015a5cxxx.r2.cloudflarestorage.com/BUCKET-A/ \
    --s3-access-key 02e87e05dc0f3c27239d6d13bd6xxxxx \
    --s3-secret-key 2f44f34783f759613b24071afeac55b06286b5e401c9exxxxx \
    --s3_endpoint https://40557a5d82224556015a5cxxx.r2.cloudflarestorage.com
```

{% endcode %}

Replace the placeholders with your actual Cloudflare R2 credentials:

* `<YOUR_S3_URI_DESTINATION>`: Your R2 bucket destination path
* `<YOUR_S3_ACCESS_KEY>`: Your R2 access key
* `<YOUR_S3_SECRET_KEY>`: Your R2 secret key
* `<YOUR_S3_ENDPOINT>`: Your R2 endpoint

After running the command, check your specified R2 destination path. You should find the `output.txt` file successfully copied.

{% hint style="success" %}
Congratulations! You've learned how to copy output files from Float16's remote storage to your Cloudflare R2 storage.
{% endhint %}

## Explore More&#x20;

Learn how to use Float16 CLI for various use cases in our tutorials.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Hello World</strong></td><td>Launch your first serverless GPU function and kickstart your journey.</td><td><a href="/pages/YApNAqisqIbe17eFghB7">/pages/YApNAqisqIbe17eFghB7</a></td></tr><tr><td><strong>Install new library</strong></td><td>Enhance your toolkit by adding new libraries tailored to your project needs.</td><td><a href="/pages/yyygZPyF40EbYlvQ9c8d">/pages/yyygZPyF40EbYlvQ9c8d</a></td></tr><tr><td><strong>Copy output from remote</strong></td><td>Efficiently transfer computation results from remote to your local storage.</td><td><a href="/pages/BPAsR6EAOJexajZPitzW">/pages/BPAsR6EAOJexajZPitzW</a></td></tr><tr><td><strong>Deploy FastAPI Helloworld</strong></td><td>Quick start to deploy FastAPI without change the code.</td><td><a href="/pages/IapDkZzfM7mN9ePptZcb">/pages/IapDkZzfM7mN9ePptZcb</a></td></tr><tr><td><strong>Upload and Download via CLI and Website</strong></td><td>Direct upload and download file(s) to server.</td><td><a href="/pages/neh6VHbUO1k5sjbJcIiZ">/pages/neh6VHbUO1k5sjbJcIiZ</a></td></tr><tr><td><strong>More examples</strong></td><td>Open source from community and Float16 team.</td><td><a href="/pages/WofUCY294VqyFMOY62JX">/pages/WofUCY294VqyFMOY62JX</a></td></tr></tbody></table>

Happy coding with Float16 Serverless GPU!


---

# 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.float16.cloud/getting-started/serverless-gpu/tutorials/r2-copy-output-from-remote.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.
