4

Say I have a domain, media.coolsite.com. Also say I have a bucket in Google Cloud Storage with the same name. I also have the cname setup properly, so that when I visit media.coolsite.com in the browser, it renders index.html in the bucket.

The bucket also contains a file 01.mp3 that I am trying to get a signed URL for. I can do this with the following code:

gcloud = Gcloud.new
storage = gcloud.storage
bucket = storage.bucket 'media.coolsite.com'
file = bucket.file '01.mp3'
signed_url = file.signed_url

This returns a URL like so:

https://storage.googleapis.com/media.coolstuff.com/01.mp3?GoogleAccessId=...&Expires=...etc...

But what I would like is a URL like this:

http://media.coolstuff.com/01.mp3?GoogleAccessId=...&Expires=...etc...

Note the different host: media.coolstuff.com instead of storage.googleapis.com.

How can I do this using the gcloud gem?

cilphex
  • 6,006
  • 6
  • 34
  • 44
  • Two questions: First, is the switch from https to http intentional in your question? Second, can you describe the use case for needing the second URL? – Travis Hobrla Nov 04 '15 at 21:28
  • 1
    1) Yes it is intentional because I don't have an SSL cert for that domain, so I assume I cannot use https. 2) It just appears more professional to have your content served from your own domain, and the intent is clearer when link sharing. Amazon lets you do it with a `virtual_host` flag: http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Presigner.html#instance_method_details . The explanation there even talks about https vs http. They default to http, though ideally i'd be able to pick, if I was able to use https with that domain. – cilphex Nov 05 '15 at 07:10
  • Thanks for the clarification. Unfortunately, GCS doesn't have support for anything like that right now, so there's no way to do this with a signed URL. Sorry. – Travis Hobrla Nov 05 '15 at 22:46
  • 1
    Yes, GCS does have support for that. The 2nd link in the example above does actually work. Locally, I just use string replacement to replace "s://storage.googleapis.com/" with "//", and that URL works. The gem should support this functionality. – cilphex Nov 05 '15 at 23:21

0 Answers0