> Every page of the ganymede website is listed in https://eugo.io/docs/ganymede/llms.txt.

# S3FS

> S3FS: Interact with data in s3. A Python demo notebook from ganymede.

Web page: https://eugo.io/docs/ganymede/demo_notebooks/data_storage/filesystems/fsspec/s3fs/
Notebook: https://eugo.io/docs/ganymede/demo_notebooks/data_storage/filesystems/fsspec/s3fs/s3fs.ipynb (source: https://github.com/eugo-inc/ganymede/blob/main/demo_notebooks/data_storage/filesystems/fsspec/s3fs.ipynb)

Description:
- Interact with data in s3

Resources:
- https://s3fs.readthedocs.io/en/latest/
- https://github.com/fsspec/s3fs

## Environment variables

This notebook reads its settings from environment variables. Set them before starting Jupyter:

- `S3_BUCKET`: name of an S3 bucket you can access

The cell downloads `ganymede-demo/example.zip` from that bucket; upload any zip archive there first.

## Example 1

Download a file from a remote path on s3 to local filesystem

```python
import os

from fsspec import filesystem
from pathlib import Path

tmp = "/tmp/ganymede_demo"
Path(tmp).mkdir(parents=True, exist_ok=True)

s3 = filesystem("s3")

local_zip_fp = f"{tmp}/example.zip"
s3.get(rpath=f"s3://{os.environ['S3_BUCKET']}/ganymede-demo/example.zip", lpath=local_zip_fp)
```
