Skip to content

Instantly share code, notes, and snippets.

@developius
Last active July 23, 2021 04:31
Show Gist options
  • Save developius/5bfd74401da82e149f23dfa8a09c7ff2 to your computer and use it in GitHub Desktop.
Save developius/5bfd74401da82e149f23dfa8a09c7ff2 to your computer and use it in GitHub Desktop.

Revisions

  1. developius revised this gist Jul 23, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    This gist shows you how to configure a Google Cloud Storage bucket CORS for use with Rails' ActiveStorage (or any other direct-upload mechanism).

    1. Update the policy JSON to reflect your setup (likely only changing the `origin` parameter)
    2. Run this:
    `
  2. developius created this gist Jul 23, 2021.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1. Update the policy JSON to reflect your setup (likely only changing the `origin` parameter)
    2. Run this:
    `
    $ gsutil cors set ./cors-json-file.json gs://<bucket-name>
    `
    20 changes: 20 additions & 0 deletions cors.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    [
    {
    "origin": ["https://example.com"],
    "responseHeader": [
    "Content-Type",
    "Content-Md5",
    "Origin",
    "Content-Disposition"
    ],
    "method": [
    "PUT",
    "POST",
    "GET",
    "HEAD",
    "DELETE",
    "OPTIONS"
    ],
    "maxAgeSeconds": 3600
    }
    ]