The ability to have temporary URLs is something that has been requested for quite some time. Since Cloud Files runs on openstack swift, we get some of the new features available, such as temporary URLs. This will allow you to create temporary URLs so your end users can consume your product, while having it expire after a few days, or minutes, so it isn’t possible to share the link, limiting unauthorized downloads.
Keep in mind, this isn’t officially supported by Rackspace yet, so you’re on your own for it, however it does work and you can start taking advantage of it now. Read on after the jump for the how-to.
The first thing we need(Aside of an account), is the API key.
You can locate this in your control panel under ‘Your Account’, if you’re using Cloud Files, you more then likely already have this. Once you have your API key, we need to create authenticate and create/set our key.
Let’s go ahead and authenticate first:
$ curl -I -X GET -H X-Auth-User:USER -H X-Auth-Key:APIKEY https://auth.api.rackspacecloud.com/v1.0 HTTP/1.1 204 No Content Server: Apache/2.2.3 (Red Hat) vary: X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass X-Storage-Url: https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48 Cache-Control: s-maxage=5028 Content-Type: text/xml Date: Mon, 16 Apr 2012 18:41:46 GMT X-Auth-Token: ~ X-Storage-Token: ~ X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/473948 Connection: Keep-Alive X-CDN-Management-Url: https://cdn.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48 Content-Length: 0
Next, let’s go ahead and make a key. It can be whatever you want (Alphanumeric) within the limitations of the header length, however I recommend just echoing out some text and making an md5 or sha of it.
$ echo -n "Random text so I can make my key with it and such" | md5sum 7acc0fe42358c0232053b3fc7254609c -
Once we have this, we can go ahead and set it on our account:
$ curl -i -X POST -H X-Auth-Token:~token -H X-Account-Meta-Temp-URL-Key:7acc0fe42358c0232053b3fc7254609c https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48 HTTP/1.1 204 No Content Content-Length: 0 Content-Type: text/html; charset=UTF-8 X-Trans-Id: txd69ae1123b4d4f8c82ab1a38bfb3a499 Date: Mon, 16 Apr 2012 19:02:22 GMT
A few notes about your key, if you change it, it will invalidate every URL you have generated after about a minute (Due to caching), additionally, you can check it by issuing a HEAD against your account, so you won’t have to invalidate all your old URLS if you forget it –
$ curl -I -H X-Auth-Token:TOKEN https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48 HTTP/1.1 204 No Content X-Account-Object-Count: 52 X-Account-Meta-Temp-Url-Key: 7acc0fe42358c0232053b3fc7254609c X-Account-Bytes-Used: 61839518344 X-Account-Container-Count: 2 Accept-Ranges: bytes Content-Length: 0 X-Trans-Id: txa90bbf3e259443d5bd4c312adddc1767 Date: Mon, 16 Apr 2012 19:31:12 GMT
After you’ve set up your key on your account, we can go ahead and generate the URL using a python script:
import hmac from hashlib import sha1 from time import time method = 'GET' expires = int(time() + TIME FROM NOW TO EXPIRE, IN SECONDS) base = 'BASEURL' path = 'PATH TO OBJECT' key = 'THE KEY YOU CREATED' hmac_body = '%s\n%s\n%s' % (method, expires, path) sig = hmac.new(key, hmac_body, sha1).hexdigest() print '%s%s?temp_url_sig=%s&temp_url_expires=%s' % (base, path, sig, expires)
For comparison, here is what mine looked like:
import hmac from hashlib import sha1 from time import time method = 'GET' expires = int(time() + 600) base = 'https://storage101.dfw1.clouddrive.com' path = '/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48/test/test.txt' key = '7acc0fe42358c0232053b3fc7254609c' hmac_body = '%s\n%s\n%s' % (method, expires, path) sig = hmac.new(key, hmac_body, sha1).hexdigest() print '%s%s?temp_url_sig=%s&temp_url_expires=%s' % (base, path, sig, expires)
Now that we have the script made, we can generate our URL and give it to end users:
$ python script.py https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48/test/test.txt?temp_url_sig=d36692ce16ff22c80769dfce0712ff6fc9e4dd6c&temp_url_expires=1334603603 $ curl -I "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_d58d266b-3601-4d95-8e96-2063c9caef48/test/test.txt?temp_url_sig=d36692ce16ff22c80769dfce0712ff6fc9e4dd6c&temp_url_expires=1334603603" HTTP/1.1 200 OK Last-Modified: Fri, 18 Nov 2011 23:32:41 GMT Accept-Ranges: bytes Etag: 8d777f385d3dfec8815d20f7496026dc Content-Type: text/plain Content-Length: 4 X-Trans-Id: txf8297b7c83d44a85bcb9d28c7141ca08 Date: Mon, 16 Apr 2012 19:03:41 GMT
Again, this exists in the Swift implementation for Rackspace Cloud, however it is not officially supported yet. If you have issues, you’re pretty much on your own. However it seems to work fine, and it will probably be in the documentation soon and officially supported, so you can start utilizing it now!
« cialis canadian pharmacies Setting up IPSEC Site to Site VPN on the Cloud »
Hi Ryuujinx,
This looks great stuff, exactly what I was looking for. You know if this will work with CDN URLs, i.e., the X-CDN-Management-Url response header from the first request? Encountered this if trying to set the temp URL key. :/
curl -i -X POST -H X-Auth-Token:AUTH_TOKEN -H X-Account-Meta-Temp-URL-Key:KEY https://cdn1.clouddrive.com/PATH
HTTP/1.1 500 Internal Server Error
Date: Sat, 28 Apr 2012 01:50:30 GMT
Server: Apache
Content-Length: 614
Connection: close
Content-Type: text/html; charset=iso-8859-1
Hey,
As far as I know, it will only work with the Storage URLs, as we haven’t set up anything with Akamai to support this over their CDN. It may come down the road, but for now this just allows a time-limited direct access to serve straight off the storage node.
Thanks! I’ve been pulling my hair out trying to dig through the Rackspace docs for this information. I’m not all that familiar with cURL, nor do I think I should be an expert just to set the Temp-URL key. This posting is a real good cookbook solution. Just what I was looking for.
Thank you! The Rackspace docs were worse than useless in describing which parts of the URL were boilerplate versus user-specific, and there’s no guide to how to discover the correct values if you’re just diving in. This was perfect.
Thanks for posting this, it is exactly what I was looking for. I’m working in Ruby though, so I translated your Python script to Ruby for those who would like to see:
base = “https://storage101.dfw1.clouddrive.com”
method = ‘GET’
expire = (Time.now + 600).to_i
key = “YOUR KEY”
path = “/v1/MossoCloudFS_4f84bf72-ef76-4c82-89de-111f8af6344g/test/test.txt”
hmac_data = “#{method}\n#{expire}\n#{path}”
signature = OpenSSL::HMAC.hexdigest(‘sha1’, key, hmac_data)
temp_url = “#{base}#{path}?temp_url_sig=#{signature}&temp_url_expires=#{expire}”
Thanks for posting this, it helped clarify some things for me. For anybody that needs it, I’ve created a Node.js Cloud Files client that supports temporary URLs https://github.com/rossj/rackit
Anyone care to share a PHP example? 🙂
I’m no PHP dev, but this should work –
anyone with a python3 example?
他妈的医生没办法了就说一声“我们已经尽力了”。现在的医生,有些就该打!!!
整天宣传着这里军演 哪里投入多少兵力军演 有事又不敢出头 原来只会打压国内老百姓啊 这样的国家能壮大? 安徽宣城人民请战 保家卫国 我爷爷就是但年的抗美援朝的志愿军 我们这好多老人都是抗美援朝的志愿军 还有一位已经过世的老人是从3大战役复原的 我们从小就受爱家爱国 保家卫国的的誓死精神 我院做敢死队 第一个参加头战 如其受着周边小国的窝囊气 还不如死在战场上的好 有美国撑腰怕什么 就是和美国干我也愿请缨出战 为国家领土完整死有何惧
有种豁然开朗的感觉,支持、支持、坚决支持!
哇太给力了,昨天我爬1楼都很费劲,今天看了这则消息我一口气爬11楼,腰不痛,腿不疼,爽歪歪了
大清早的看到这个消息,,心里一下子爽了多,,,真是他个爽啊!~
武汉艺考 https://www.ykzhongguo.com/
These Are The Best Sex Apps For No Strings Attached Sex (3296 sexy single girls in your location): http://therhostpase.tk/r953?&yjlvg=1aIo9iUYH8z
10 Best AU Dating Sites 2019 (1999 sexual single girls in your city): http://ingatertwin.tk/mxbu3?&srztx=avmof
Best Dating Apps 2019 (1488 single women in your location): http://prepcomricsgar.ga/6fm83?&rrxkn=I4VJP
nice
nubilesporn.com
studio
Nuru Massage: erotic massage midtown
We greet you! Our firm those who make your daily life much easier . Specialized company that active more than seven years.
Distinctivefeature our Chinese salon is not an enforced setting. We advertise sites to advertising.
Recommended for you check some method massage alreadytoday. Employees of our company we are waiting client in our SPA.
(palimpsests). In the XIII-XV centuries in
reproduced by hand, in contrast
Middle Ages as in Western
monuments related to deep
Очень часто появляется потребность расслабиться. Ежедневные заботы не очень хорошо сказываются на психологическом состоянии. В такое время нужно позволить своему мозгу отдохнуть. Нет времени? 10 минут можно найти всегда. Встаньте, сделайте зарядку и гляньте что-нибудь забавное, например: смешные картинки и видео, а сайт ДжоксЛэнд вам в этом поспособствует: вот здесь
Ведь там представлено множество смешных информационных подборок.
Что можно найти на сайте для развлечений в сети?
– Забавные видео-ролики: приколы про животных, розыгрыши на первое апреля, розыгрыши и др.
– Demotivators: самые забавные про машины и философское отношение к миру и т.д.
– Интересные новостные сводки, смешные фрагменты из ток-шоу и полезные рекомендации по разным областям.
В общем, выделите 10 минут в своем расписании для того, чтобы переключиться и начать работать с новым вдохновением.
Если этот топик попал не в тот раздел, очень вас просим отправить туда, где обычно размещаются такие топики.
Since manuscripts are subject to deterioration
Middle Ages as in Western
from lat. manus – “hand” and scribo – “I write”) ]
consists of the book itself
55 thousand Greek, 30 thousand Armenian
European glory, and even after
handwritten books were made,
Europe, and in Ancient Russia
from lat. manus – “hand” and scribo – “I write”) ]
among them acquired “Moral
bride, Julie d’Angenne.
Century to a kind of destruction:
55 thousand Greek, 30 thousand Armenian
from lat. manus – “hand” and scribo – “I write”) ]
“Julia’s Garland” (fr. Guirlande de Julie)
European glory, and even after
55 thousand Greek, 30 thousand Armenian
among them acquired “Moral
Century to a kind of destruction: