Sign up or login to your DigitalOcean account.
Create a new "Space", and give it a name, i usually give it the same name as the clients website name, A "Space" is a separate container for your assets. so you can separate files across projects, think of it like a project folder.
Then go to the "API" section in the sidebar and create a new "Spaces access keys", save the Secret and the API Key,
Download and install the DO Spaces plugin.
# Install it composer require vaersaagod/dospaces # Enable it php craft install/plugin dospaces
<?php return [ // This key should be the same as your volume's "handle" 'files' => [ 'hasUrls' => true, 'url' => sprintf("https://%s.%s.digitaloceanspaces.com/", getenv('SPACES_BUCKET'), getenv('SPACES_REGION')), 'keyId' => getenv('SPACES_API_KEY'), 'secret' => getenv('SPACES_SECRET'), 'endpoint' => getenv('SPACES_ENDPOINT'), 'region' => getenv('SPACES_REGION'), 'bucket' => getenv('SPACES_BUCKET'), ], ];
Now add the following to your .env file, replace the SPACES_API_KEY, SPACES_SECRET and SPACES_BUCKET keys with the API key and API Secret you got from Digital Ocean, the bucket is the name of your DO Space.
NOTE: I by default use AMS3 as the location of the space, if you don't use AMS3, you have to update the SPACES_ENDPOINT to use the correct subdomain.
## Digital Ocean Spaces Config SPACES_API_KEY="AAAAAAAAAAAAAAAAAAAA" SPACES_SECRET="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" SPACES_ENDPOINT="https://ams3.digitaloceanspaces.com" SPACES_REGION="ams3" SPACES_BUCKET="CUSTOMER-NAME"
You now have setup your Craft CMS site to use Digital Ocean Spaces to store your assets, now all uploaded files will be uploaded to Digital Ocean, no matter if you're in local development, staging or production.
Host your CraftCMS websites with a secure, affordable and easy to manage VPS provider.Get $10 free credits on signup
Book 1:1 help from me on CodeMentor, get expert advice and help with CraftCMS, Flutter or Laravel.