1

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}")
ehay
  • 21
  • 3

1 Answers1

1

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.

colinm
  • 4,258
  • 24
  • 19
  • Hey Colin, I've tried that and I get a connection refused error. I'm going to add my code to post, please let me know if you spot the error. Thanks. – ehay Jun 13 '14 at 19:51
  • @ehay Crud. While this used to work, after poking around for a bit it *appears* Rackspace no longer serves Cloud Files over HTTP. You might want to verify that with support. If you don't need the access control, CDN-enabled containers definitely support HTTP and load much, much more quickly. – colinm Jun 13 '14 at 21:03
  • If you do need the access control, Amazon CloudFront does currently offer that. I know there were discussions of considering access control for the Rackspace CDN, but it doesn't appear that's gone anywhere. You can [take the CDN survey](https://surveys.rackspace.com/Survey.aspx?s=0d01aa500cea4dbd9d6d8043e1d23e6e) to express your interest. – colinm Jun 13 '14 at 21:25