MENU

Description

一時的にオブジェクトを公開する場合に、使用します。
Temp-Url-Keyを登録後に、下記方法等にてURLを作成する必要があります。

・URL作成スクリプトを作成する
・Swift-temp-urlクライアントを使用する

Request URL

Swift API v1.0

POST /v1/nc_​{account}​

Request Parameters

Parameter Value Style Description
X-Auth-Token Userトークン header
account tenant ID URI
container コンテナ名 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

※エンドポイントURLにつきましては、お客様環境によって異なりますので、コントロールパネルにてご確認の上ご利用ください。

  • REQ
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.conoha.io/v1/nc_cc54f7476b8e444bad238a943a94ccdf
  • RES
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.コンテナを作成し、オブジェクトをアップロード

1.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.conoha.io/v1/nc_cc54f7476b8e444bad238a943a94ccdf

2.tempurl生成する為、下記モジュールを作成(24時間で生成する場合)

#vim create-tempurl.py
import hmac
from hashlib import sha1
from time import time
method = 'GET'
duration_in_seconds = 60*60*24 ←[時間]
expires = int(time() + duration_in_seconds)
path = '/v1/nc_cc54f7476b8e444bad238a943a94ccdf/container/object' ←[対象オブジェクト]
key = 'test-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.conoha.io', path=path, sig=sig, expires=expires)
print '%s' % url

3.モジュールを実行

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