Skip to content

Commit

Permalink
Minor changes to make it work with Google Cloud Storage instead
Browse files Browse the repository at this point in the history
  • Loading branch information
timwhite committed Oct 5, 2015
1 parent 87bd0a0 commit 8b55698
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions classes/amazon-s3-and-cloudfront.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Amazon_S3_And_CloudFront extends AWS_Plugin_Base {
const DEFAULT_ACL = 'public-read'; const DEFAULT_ACL = 'public-read';
const PRIVATE_ACL = 'private'; const PRIVATE_ACL = 'private';
const DEFAULT_EXPIRES = 900; const DEFAULT_EXPIRES = 900;
const DEFAULT_REGION = 'us-east-1'; const DEFAULT_REGION = 'global';


const SETTINGS_KEY = 'tantan_wordpress_s3'; const SETTINGS_KEY = 'tantan_wordpress_s3';


Expand Down Expand Up @@ -998,7 +998,7 @@ function get_file_prefix( $time = null, $post_id = null ) {
* @return string * @return string
*/ */
function get_s3_url_prefix( $region = '', $expires = null ) { function get_s3_url_prefix( $region = '', $expires = null ) {
$prefix = 's3'; $prefix = 'storage';


if ( '' !== $region ) { if ( '' !== $region ) {
$delimiter = '-'; $delimiter = '-';
Expand Down Expand Up @@ -1046,10 +1046,10 @@ function get_s3_url_domain( $bucket, $region = '', $expires = null, $args = arra
$s3_domain = $bucket; $s3_domain = $bucket;
} }
elseif ( 'path' === $args['domain'] || $this->use_ssl( $args['ssl'] ) ) { elseif ( 'path' === $args['domain'] || $this->use_ssl( $args['ssl'] ) ) {
$s3_domain = $prefix . '.amazonaws.com/' . $bucket; $s3_domain = $prefix . '.googleapis.com/' . $bucket;
} }
else { else {
$s3_domain = $bucket . '.' . $prefix . '.amazonaws.com'; $s3_domain = $bucket . '.' . $prefix . '.googleapis.com';
} }


return $s3_domain; return $s3_domain;
Expand Down
4 changes: 2 additions & 2 deletions view/domain-setting.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<label class="subdomain-wrap <?php echo $subdomain_class; // xss ok?>"> <label class="subdomain-wrap <?php echo $subdomain_class; // xss ok?>">
<input type="radio" name="domain" value="subdomain" <?php checked( $domain, 'subdomain' ); ?> <?php echo $subdomain_disabled; // xss ok ?>> <input type="radio" name="domain" value="subdomain" <?php checked( $domain, 'subdomain' ); ?> <?php echo $subdomain_disabled; // xss ok ?>>
<?php _e( 'Bucket name as subdomain', 'amazon-s3-and-cloudfront' ); ?> <?php _e( 'Bucket name as subdomain', 'amazon-s3-and-cloudfront' ); ?>
<p>http://bucket-name.s3.amazon.com/&hellip;</p> <p>http://bucket-name.storage.googleapis.com/&hellip;</p>
</label> </label>
<label> <label>
<input type="radio" name="domain" value="path" <?php checked( $domain, 'path' ); ?>> <input type="radio" name="domain" value="path" <?php checked( $domain, 'path' ); ?>>
<?php _e( 'Bucket name in path', 'amazon-s3-and-cloudfront' ); ?> <?php _e( 'Bucket name in path', 'amazon-s3-and-cloudfront' ); ?>
<p>http://s3.amazon.com/bucket-name/&hellip;</p> <p>http://storage.googleapis.com/bucket-name/&hellip;</p>
</label> </label>
<label> <label>
<input type="radio" name="domain" value="virtual-host" <?php checked( $domain, 'virtual-host' ); ?>> <input type="radio" name="domain" value="virtual-host" <?php checked( $domain, 'virtual-host' ); ?>>
Expand Down

2 comments on commit 8b55698

@jiji0806
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, not sure if you will check this comment, but there was no way reach you.

I was looking for this exactly.

  1. I tried with azure blob storage(there is plugin for azure). but, there was no way to import my existing wordpress media library files to the azure storage, which is size about 200GB ( there are azcopy and few more tools but they are only for windows machine, I need linux CLI so that I can command upload files directly from my live server to the cloud storage.)

google and aws s3 has linux CLI that I can upload my heavy media library to the cloud storage.

so now, I try to look up any existing plugin for google cloud storage connect to wordpress media library.but no luck except this one. every one seems to build plugin for google drop box, not for "google cloud storage".

r u planning to build native Google Cloud Storage plugin for wordpress??

I may wait for it...

if you are not planning, I have to work with aws S3...

any replying will be appreciate, thanks

@timwhite
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://tim.purewhite.id.au/2015/10/wordpress-google-cloud-storage/

Have a look at that blog post. That shows how with the AWS plugin (and this one because it uses Google's S3 API as well) can upload your existing media library easily. Just this plugin and wp-cli required and a simple bash script.

Ideally I'd like to build a native Google Cloud Storage plugin, or Backblaze B2 plugin. Realistically that won't happen for awhile due to time constraints.

Hope that helps. Easiest way to respond to the blog post is to open an issue on the post (https://github.com/timwhite/technicallytim/issues)

Please sign in to comment.