Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pixeldevsio/4509cea4c158da85e94804072c9ab915 to your computer and use it in GitHub Desktop.
Save pixeldevsio/4509cea4c158da85e94804072c9ab915 to your computer and use it in GitHub Desktop.
Use HumanMade S3 plugin with Digital Ocean Spaces
These are the two steps you need to take to get S3 to work with Digital Ocean Spaces.
https://github.com/humanmade/S3-Uploads
<?php
/**
* Plugin Name: S3 Uploads DigitalOcean Helper
* Plugin URI: https://www.pixeldevs.io
* Description: Helper file to get DigitalOcean Spaces working with S3 Uploads
* Version: 1.0
* Author: PixelDevs
* Author URI: https://www.pixeldevs.io
**/
// Filter S3 Uploads params.
add_filter( 's3_uploads_s3_client_params', function ( $params ) {
if ( defined( 'S3_UPLOADS_ENDPOINT' ) ) {
$params['endpoint'] = S3_UPLOADS_ENDPOINT;
$params['use_path_style_endpoint'] = true;
$params['debug'] = false; // Set to true if uploads are failing.
}
return $params;
}, 5, 1 );
// ADD THIS FILE TO mu-plugins folder in wp-content
// ADD THIS TO wp-config.php
define( 'S3_UPLOADS_BUCKET', 'aaaccdn' );
define( 'S3_UPLOADS_REGION', 'sfo3' ); // the s3 bucket region (excluding the rest of the URL)
// You can set key and secret directly:
// THESE ARE YOUR SPACES ACCESS KEYS IN DIGITAL OCEAN | API > SPACES ACCESS KEYS
define( 'S3_UPLOADS_KEY', 'itsTheSmallerOne' );
define( 'S3_UPLOADS_SECRET', 'ItsTheLargerOne' );
// Or if using IAM instance profiles, you can use the instance's credentials:
define( 'S3_UPLOADS_USE_INSTANCE_PROFILE', true );
define('S3_UPLOADS_BUCKET_URL', 'https://aaaccdn.sfo3.digitaloceanspaces.com');
define('S3_UPLOADS_ENDPOINT', 'https://sfo3.digitaloceanspaces.com');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment