Rackspace CloudFiles HTTP Temp URL (Not HTTPS)

279 Views Asked by At

I have a rails application that allows users to upload audio and video. The audio and video are then delivered to our HTML5 App. We are using rackspace CloudFiles (private) to store all of the file and everything works nicely.

The problem is trying to get the video to Android users (Android doesn't like to play HTTPS media files).

To solve this I am looking for a way to create the temp url without an HTTPS link.

Any help wold be greatly appreciated.

Thanks.

require "openssl"

cloudfiles_folder = FOLDER_NAME
url_string = ASSET_URL_STRING_FROM_PAPERCLIP

method = "GET"
base_url, object_path = ("http://storage101.ord1.clouddrive.com/v1/MossoCloudFS_HIDING_REST_OF_URL/"+cloudfiles_folder+"/"+url_string ).split(/\/v1\//)

object_path = "/v1/" + object_path
seconds     = 1200
expires     = (Time.now + seconds).to_i
hmac_body   = "#{method}\n#{expires}\n#{object_path}"
sig         = OpenSSL::HMAC.hexdigest("sha1", ENV["RACKSPACE_TEMP_URL_KEY"], hmac_body)

puts ("#{base_url}#{object_path}?" + "temp_url_sig=#{sig}&temp_url_expires=#{expires}")
1

There are 1 best solutions below

3
On

The answer's deceptively simple: Just use HTTP.

Tempurl requests are not signed with the protocol—only the request type, expiry, and object path. A token that's valid for HTTPS is equally valid for HTTP.

If you're using fog, you can easily do this by setting the instance scheme to HTTP or passing scheme: 'http' in your options hash.