Storage googleapis cors

Video Storage googleapis cors

Login:

Google Cloud Storage

You’ll want to login using an official Google account (i.e. if this is for your company, use the comapany Gmail account vs. a personal one.)

When logging in, you might be prompted to verify the account; if so, enter your cell number to get a verification e-mail or phone call.

Once verified, you’ll have to agree to the terms of service; do that, and click continue.

Create a project:

Create a new project; here’s an example project name:

Acme Co. Web Fonts

You’ll then be directed to the “Welcome to Google Cloud Console” page.

Under “Cloud products”, click “Go to Cloud Storage” under the “Cloud Storage” header.

You’ll be taken to a URI that looks like so:

https://code.google.com/apis/console

Once there, you’ll see this message:

“Google Cloud Storage is not active on this project”

Read more: Which olympic games had the largest attendance

Click the big blue “Enable” button.

Next, you’ll see this message:

“You must sign up for billing before you will be able to create any buckets.”

Google Cloud Storage Pricing:

Google Cloud Storage: Pricing and Support

Setup billing:

Click on the “Billing” link.

Click “Enable Billing” and setup your “Billing Profile”.

Follow the instructions.

Create a bucket:

Once billing has been setup, continue on to the Google Cloud Storage Manager.

Create a new bucket by clicking the “New Bucket” button in top-right of interface.

If you’re planning on setting up a CNAME for your bucket, you’ll want to follow this naming convention:

fonts.acmecompany.com

Upload content:

Once you’ve created your bucket, upload your web fonts and related assets.

Note: For every file you want to share publicly, click the “Share Publicly” check mark in the file list view of the Google Cloud Storage Manager.

Setup CNAME:

Read more: Formidable login form error message

Next, create your CNAME:

fonts.acmecompany.com CNAME c.storage.googleapis.com

Where fonts.acmecompany.com is your bucket name and c.storage.googleapis.com is the host endpoint.

Install and configure the API:

Now, download the gsutil Python API to your Mac.

Read these docs:

Google Cloud Storage: Install gsutil

Google Cloud Storage: gsutil Tool

Tip: use $ gsutil config -b and follow the instructions.

Once installed, and configured, you can access your bucket via the terminal shell.

Create CORS file:

Next, setup a CORS file:

Google Cloud Storage: Cross-Origin Resource Sharing (CORS)

Set CORS file:

In terminal, get the CORS:

Setting CORS:

Interesting info here:

Read more: Disney characters with purple hair

Http Header Vary: Origin causes cache fail in Internet Explorer in Google Cloud Storage

Example usage:

Some more info here:

Google Cloud Storage: Request Body Elements for CORS

Website configuration:

Now, we need to setup index.html and 404.html files:

Google Cloud Storage: Website Configuration

Set default index and 404 error pages:

@TODO:

  • Figure out how to set caching on uploaded files.
  • Other optiomizations?

Discussions:

  • Amazon Web Services Discussion Forums: S3, CORS and web fonts randomly failing to load?
  • Google Groups: Google Cloud Storage: CORS and custom web fonts

Related Gists:

  • Amazon S3 snippets… Transmit FTP settings… Other related goodies…

If you need to connect to multiple Google Cloud Storage acounts (say, a work and personal account), you’ll need to setup a .boto file for each account.

Here’s how I did it:

Run $ gsutil config -b (from steps above) for each Google Cloud Storage account; afterwords, you’ll find a ~/.boto and a ~/.boto.bak file (the latter being the .boto file from the first time you ran the config setup). Re-name ~/.boto.bak to something more useful (like .boto-other) then you can add this line to your ~/.bash_profile:

Now you can run (for example):

… and:

$ gsutil getcors gs://fonts.work-site.com/

More information can be found here:

  • Google Groups: Google Cloud Storage: How to handle multiple Storage accounts using gsutil?
  • Google Groups: Google Cloud Storage: gsutil

Related Posts