Last active
December 19, 2015 08:19
-
-
Save cmattson/5924864 to your computer and use it in GitHub Desktop.
Ruby version of Rackspace's example form signing code. Full details on Cloud Files FormPost capability are in the API docs:
http://docs.rackspace.com/files/api/v1/cf-devguide/content/FormPost-d1a555.html sprintf is used here because it breaks across multiple lines nicely; there's nothing stopping you from using inline interpolation (heck, or con…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
path = '/v1/account/container/object_prefix' | |
redirect = 'https://myserver.com/some-page' | |
max_file_size = 104857600 | |
max_file_count = 10 | |
expires = (Time.now.to_i + 600) | |
key = 'mykey' | |
hmac_body = sprintf("%s\n%s\n%s\n%s\n%s", path, redirect, max_file_size, max_file_count, expires) | |
signature = OpenSSL::HMAC.hexdigest('sha1', key, hmac_body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works great.. thanks!