# Complex to Simple: DigitalOcean Spaces

*Dmytro Bobryshev · 13 dec 2025*

> DigitalOcean Spaces is a simple, scalable cloud storage solution for managing files like media, backups, and logs outside your application. With S3 compatibility, stateless architecture support, and easy setup, it’s a practical choice for handling data efficiently while keeping your app lightweight and independent.

---

## What is DigitalOcean (DO) Spaces ?

DigitalOcean Spaces - is a cloud storage service, where you can keep all your digital items in a “spaces bucket” — our special cloud-based folder.

| Usage | Features |
| --- | --- |
| Stateless architecture | No worries about disk space |
| Backups | Independent storage |
| Archive logs | External service that manages data storage |
| Media data (photos, videos, docs, etc.) | Sharing access |
| Personal / Secret data (contracts, invoices, passports, etc.) | Ability to have Stateless architecture |

## Differences between DO Spaces & AWS S3

| DigitalOcean Spaces | AWS S3 |
| --- | --- |
| Very simple console | Functional console |
| Compatible with S3 APIExternal CDN supportACL policy | Compatible with AWS services such as:Amazon CloudFront (for content delivery)Amazon Glacier (for long-term archival)AWS Lambda (for server-less computing) |
| Scalability: Petabyte-scale | Scalability: Virtually unlimited |
|  | Video/image compressor/convertor |

![do-console](https://cdn.sanity.io/images/z7im7se7/production/c891d25292465989d746e13187b9375d9f5c04cd-2560x1287.webp)

![aws-s3-console](https://cdn.sanity.io/images/z7im7se7/production/a783cbdf540c70e70c991d9cce4f2e7c16d48118-2706x1834.webp)

## How to create DO Space ?

1. Go to the [DigitalOcean Console](https://cloud.digitalocean.com/projects/)
1. Choose the **“Spaces Object Storage“** in the sidebar

![do-sidebar](https://cdn.sanity.io/images/z7im7se7/production/452729c9f1992d5d6d9fd5ea0bd1ee74607bad7a-215x1287.webp)

![do-console](https://cdn.sanity.io/images/z7im7se7/production/c891d25292465989d746e13187b9375d9f5c04cd-2560x1287.webp)

1. Click to the **“Create Spaces Bucket“ **for create single space:
1. Fill in the following fields in the image shown:
*For most cases on EU projects, Frankfurt will be the best option as it is supposed to be in the same data center as the VPS/Database*

![create-do-spaces](https://cdn.sanity.io/images/z7im7se7/production/620ad5a38c82b052b5fd4deb8901bc74940f691c-1300x1290.webp)

1. Paste the shown DO variables to config and Forge environments.

## Setup DigitalOcean CORS domains

if you see the same error, follow the steps below:

![show-cors-errors-the-console](https://cdn.sanity.io/images/z7im7se7/production/c368dce67a75d74ef83cdf80160afc41cece1637-1980x1344.webp)

1. Select the Relevant Project and Space:In the sidebar, choose the project or DO spaces directly.Select the space or spaces (if we have more that one).

![select-spaces](https://cdn.sanity.io/images/z7im7se7/production/883f3a7acbdf1b36f21812e374dd050595682c38-2007x1290.webp)

1. Update CORS Configurations

![add-new-setting](https://cdn.sanity.io/images/z7im7se7/production/a3bf3bb5a5d8fd4ea3a2a17fd735dbc9bfeddf63-1500x1290.webp)

![configuring-cors](https://cdn.sanity.io/images/z7im7se7/production/2e3974eb92ebce3de712d8055f86b0fd97c23beb-1500x1290.webp)

> *All "API" or "Monolith apps" domains could support all* `HTTP` *methods* (`GET`, `PUT`, `DELETE`, `POST`, `HEAD`). *The basic domain (like apps which only reached the content from API) could only allow the* `GET` *method for enhanced security, limiting interactions to data retrieval.*

### Example configuration:

```yaml
# API or Monolith apps domains:

Origin: https://example-api-domain.com
Allowed Methods: GET, PUT, DELETE, POST, HEAD
Allowed Headers: # No additional headers selected
Access Control Max Age: 0 # set this up by your requirements
```

```yaml
# Reached content domains:

Origin: https://example-domain.com
Allowed Methods: GET
Allowed Headers: # No additional headers selected
Access Control Max Age: 0 # set this up by your requirements 
```

## Implement DO Spaces to Laravel Project

1. Install the [following package](https://flysystem.thephpleague.com/docs/getting-started/) to your Laravel project:
1. Update configs:

```php
-  'default_media_disk_name' => 'media',
+  'default_media_disk_name' => 'do_spaces',
```

Don’t forget add/update variables to “Environments“

```php
'do_spaces' => [
    'driver' => 's3',
    'key' => env('DO_SPACES_KEY'),
    'secret' => env('DO_SPACES_SECRET'),
    'endpoint' => env('DO_SPACES_ENDPOINT'),
    'region' => env('DO_SPACES_REGION'),
    'bucket' => env('DO_SPACES_BUCKET'),
],
```