Description

Use when you publish the object temporaily
You need to create a URL after registrating Temp-Url-Key. The procedure is as follows.

・Create a script to generate URL
・Use Swift-temp-url client

Request URL

Swift API v1.0

POST /v1/zc_{account}​

Request Parameters

Parameter Value Style Description
X-Auth-Token User Token header
account tenant ID URI
container Container Name URI
X-Account-Meta-Temp-URL-Key (Optional) string header
X-Remove-Account-Meta-Temp-URL-Key (Optional) string header

Request Json

This operation does not accept a request body.

Normal response code

204

Example

curl -i -X POST \
-H "Accept: application/json" \
-H "X-Auth-Token: 2c6f2de2126a4102b38368c32e7043db" \
-H 'X-Account-Meta-Temp-URL-Key: test-key' \
https://object-storage.tyo1.cloud.z.com/v1/nc_cc54f7476b8e444bad238a943a94ccdf
HTTP/1.1 204 No Content
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: tx28cf23ab8fec427ab635e-00554c34eb
Date: Fri, 08 May 2015 04:00:43 GMT

using

0.Create a container and upload a object.

1.Set tempurl Key

curl -i -X POST \
-H "Accept: application/json" \
-H "X-Auth-Token: 2c6f2de2126a4102b38368c32e7043db" \
-H 'X-Account-Meta-Temp-URL-Key: test-key' \
object-storage.tyo1.cloud.z.com/v1/nc_cc54f7476b8e444bad238a943a94ccdf

2.Create a module below to generate a tempurl. (generate by 24 hours)

#vim create-tempurl.py
import hmac
from hashlib import sha1
from time import time
method = 'GET'
duration_in_seconds = 60*60*24 ←[Time]
expires = int(time() + duration_in_seconds)
path = '/v1/nc_cc54f7476b8e444bad238a943a94ccdf/container/object' ←[Object]
key = 'test-key' ←[Key]
hmac_body = '%s\n%s\n%s' % (method, expires, path)
sig = hmac.new(key, hmac_body, sha1).hexdigest()
s = 'https://{host}{path}?temp_url_sig={sig}&temp_url_expires={expires}'
url = s.format(host='object-storage.tyo1.cloud.z.com', path=path, sig=sig, expires=expires)
print '%s' % url

3.Execute a Module

#/usr/bin/python create-tempurl.py