DigitalOcean Spaces Quick Start Guide
If you’re already using WP Offload Media with Amazon S3 and wanting to start using DigitalOcean Spaces instead, please use our How to Move from Amazon S3 to DigitalOcean Spaces guide.
We also have an Amazon S3 Quick Start Guide.
This article covers the following steps:
- Login to the DigitalOcean Control Panel
- Create DigitalOcean Spaces Access Keys
- Saving the access details for WP Offload Media to use
- Activate Your WP Offload Media License
- Configure WP Offload Media to offload newly uploaded media to a DigitalOcean Spaces bucket
- Offload Your Existing Media Library
- Next steps for setting up WP Offload Media to use a CDN
Login to the DigitalOcean Control Panel
Already have a DigitalOcean account? Sign in here.
If you don’t have a DigitalOcean account yet, you will need to sign up here.
Create Access Keys
Once you have logged into the DigitalOcean Control Panel, you will need to create Access Keys for Spaces.
Navigate into the Spaces area from the “Manage” section of the Control Panel’s left-hand menu, then click the “Manage Keys” button.
Scroll down to the Spaces Access Keys section, click the “Generate New Key” button.
Enter a name for the new Access Keys so they are easy to identify, click the “tick” button to save.
You will be shown the security credentials for the access keys, which consists of an Access Key ID and a Secret Access Key. DigitalOcean will not show the Secret Access Key again so copy both keys somewhere safe. If you lose them, you can always create a new set of keys, but you cannot retrieve the secret key again later.
Define Your Access Keys
Now that you have your DigitalOcean Access Keys, you need to add them to your site so that WP Offload Media can use them to work with the DigitalOcean Spaces service.
For better security, we recommend defining your access keys in your
define( 'AS3CF_SETTINGS', serialize( array( 'provider' => 'do', 'access-key-id' => '********************', 'secret-access-key' => '**************************************', ) ) );
These should be placed before the following block of code in your
/* That's all, stop editing! Happy blogging. */ /** Absolute path to the WordPress directory. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php');
Warning: If you define your access keys after this block of code, WP Offload Media will not be able to read them.
Alternatively, you can enter your access keys into the form on the Storage Provider page inside WP Offload Media, the first page shown when no keys are defined. This will save them to the database, which is less secure than defining them in your
Make Sure Cron is Set Up
We highly recommend that you configure a proper cron job on your server as WP Offload Media relies heavily on background processing. See our Cron Setup doc for details on how to accomplish this.
Activate Your WP Offload Media License
Now’s a good time to activate your WP Offload Media license so that once configured you can instantly take advantage of all its goodies.
Go to WP Offload Media’s settings page in the WordPress admin dashboard, it can be found under the “Settings” menu.
Then click on the “License” tab, enter your license key in the input box, and click the “Activate License” button.
Configure WP Offload Media
To start offloading newly uploaded media to DigitalOcean Spaces you need to first tell WP Offload Media which bucket (Space) it should use. If you have not already created a bucket to use with WP Offload Media, it can be created for you from WP Offload Media’s settings page.
Go to the “Media Library” tab of WP Offload Media’s settings page in the WordPress admin dashboard. If you have followed the steps above then you should see something like the following.
If you have already created the bucket you want to offload your media to then you can simply enter the bucket name in the above input and click the “Save Bucket” button.
If you haven’t created the bucket yet, then you can click the “Create new bucket” link to get a form where you can specify the new bucket’s name and region.
You can also “Browse existing buckets”.
Regardless of how you specify the bucket, once saved, WP Offload Media will be set up to offload newly uploaded media to the bucket with some recommended default settings.
Offload Your Existing Media Library
Now that your site is configured to offload newly uploaded media to DigitalOcean Spaces, you might want to offload any existing media to the bucket too.
In the right-hand sidebar of WP Offload Media’s “Media Library” tab you should see what we call the “Offload Tool”, this can be used to offload existing media to the bucket.
If you have not offloaded anything yet, then you’ll see a “Your Media Library needs to be offloaded” message in the Offload Tool with an “Offload Now” button.
If you have already offloaded a few items, then you might see a message like “66% of your Media Library has been offloaded” in the Offload Tool, with an “Offload Remaining Now” button.
Either way, clicking the Offload Tool’s button will start an upload to the bucket of all existing media yet to be offloaded.
The offload progresses in small batches of media to keep things performant. You need to keep the browser window or tab open on that page until the upload to the bucket completes.
Once complete, the Offload Tool displays a “100% of your Media Library has been offloaded, congratulations!” message and the “Download all files from bucket to server” and “Remove all files from bucket” tools are made available.
Next Steps: Using a Content Delivery Network (CDN)
Now that your media is offloaded to DigitalOcean Spaces, your next step if you’re concerned about performance (i.e. load time and SEO), is to configure a Content Delivery Network (CDN).
By default WP Offload Media is configured to use raw DigitalOcean Spaces URLs when serving offloaded media. Your media URLs might look something like this:
Not only is this an ugly URL, but this URL is also bad for SEO as Google likes to see your media on your own domain. Also, DigitalOcean Spaces is primarily a storage platform and is not optimized for high speed delivery of media. Faster-loading media is obviously better for user experience but also better for SEO. For these reasons, we strongly recommend configuring a CDN with custom domain for delivering your media. The built-in DigitalOcean Spaces CDN does not currently support custom domains so we don’t recommend using that until they fully support custom domains. For more details about the benefits of using a CDN, please read our Why Use a CDN? doc.
We have two guides specific to setting up a CDN for media offloaded to DigitalOcean Spaces…