如何在php中为Rackspace Cloud API设置元数据密钥


How set Meta data key in php for Rackspace Cloud API

我在PHP中使用Rackspace云服务器的云文件API,我想生成一个临时url来下载文件,以便直接下载到我的服务器。我使用这个API的get_temp()方法,但在使用这个方法之前,我必须为我的容器设置元数据密钥。我该怎么做呢。

 public function get_temp_url($key, $expires, $method)
{
    $expires += time();
    $url = $this->container->cfs_http->getStorageUrl() .  '/' . $this->container->name . '/' . $this->name;
    return $url . '?temp_url_sig=' . hash_hmac('sha1', strtoupper($method) .
           "'n" . $expires . "'n" . parse_url($url, PHP_URL_PATH), $key) .
           '&temp_url_expires=' . $expires;
}

此页面上的注释包括如何设置的示例:

http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html

此外,如果您使用新的云文件API。。。

https://github.com/rackspace/php-opencloud

它在ObjectStore类中包含一个SetTempUrlSecret方法,该方法将为您执行此操作。