---
title: DigitalOcean Spaces
icon: /images/digitalocean-logo.svg
description: Mount a DigitalOcean Spaces bucket via its S3-compatible API as a virtual filesystem.
---
The DigitalOcean resource is a thin wrapper over the [S3 resource](/python/resource/s3).
It maps a `DigitalOceanConfig` to an `S3Config` and reuses the exact same
backend, commands, and behavior as S3, it just derives the right Spaces
endpoint from `region`. Uses aioboto3 against DigitalOcean Spaces'
S3-compatible API.

The endpoint is computed from `region` as `<region>.digitaloceanspaces.com`
(e.g. `nyc3.digitaloceanspaces.com`). Pass `endpoint_url` to override.

## Config

```python
import os

from mirage import MountMode, Workspace
from mirage.resource.digitalocean import DigitalOceanConfig, DigitalOceanResource

config = DigitalOceanConfig(
    bucket=os.environ["DO_SPACE"],
    region=os.environ.get("DO_REGION", "nyc3"),
    access_key_id=os.environ["DO_ACCESS_KEY_ID"],
    secret_access_key=os.environ["DO_SECRET_ACCESS_KEY"],
    # Optional:
    # endpoint_url="https://nyc3.digitaloceanspaces.com",
    # timeout=30,
    # proxy="http://proxy:8080",
)
resource = DigitalOceanResource(config)
ws = Workspace({"/data": resource}, mode=MountMode.READ)
```

Both `READ` and `WRITE` modes are supported.

## Example

```python
import asyncio
import os

from dotenv import load_dotenv

from mirage import MountMode, Workspace
from mirage.resource.digitalocean import DigitalOceanConfig, DigitalOceanResource

load_dotenv(".env.development")

config = DigitalOceanConfig(
    bucket=os.environ["DO_SPACE"],
    region=os.environ.get("DO_REGION", "nyc3"),
    access_key_id=os.environ["DO_ACCESS_KEY_ID"],
    secret_access_key=os.environ["DO_SECRET_ACCESS_KEY"],
)
resource = DigitalOceanResource(config)


async def main() -> None:
    ws = Workspace({"/data/": resource}, mode=MountMode.READ)

    r = await ws.execute("ls /data/")
    print(await r.stdout_str())

    r = await ws.execute("tree /data/")
    print(await r.stdout_str())


if __name__ == "__main__":
    asyncio.run(main())
```

## Notes

- DigitalOcean reports `ResourceName.S3` and routes through the same `core/s3`
  implementation, so the full S3 shell-command set applies. See the
  [S3 resource](/python/resource/s3) for the complete command reference,
  range reads, streaming, and the index cache fast path.
- For credential setup, see [DigitalOcean Setup](/home/setup/digitalocean).
