Temporary URLs

Temporary URLs allow you to create time-limited Internet addresses that allow you to grant access to your Cloud Files account. Using Temporary URL, you may allow others to retrieve or place objects in your containers - regardless of whether they’re CDN-enabled.

Set “temporary URL” metadata key

You must set this “secret” value on your account, where it can be used in a global state:

$account = $service->getAccount();
$account->setTempUrlSecret('my_secret');

echo $account->getTempUrlSecret();

The string argument of setTempUrlSecret() is optional - if left out, the SDK will generate a random hashed secret for you.

Get the executable PHP script for this example:

Create a temporary URL

Once you’ve set an account secret, you can create a temporary URL for your object. To allow GET access to your object for 1 minute:

$object->getTemporaryUrl(60, 'GET');

To allow PUT access for 1 hour:

$object->getTemporaryUrl(360, 'PUT');

Get the executable PHP script for this example

Hosting HTML sites on CDN

Note

This feature is only available to Rackspace users.

To host a static (i.e. HTML) website on Cloud Files, you must follow these steps:

  1. CDN-enable a container:
$container = $service->getContainer('html_site');
$container->enableCdn();
  1. Upload all HTML content. You can use nested directory structures.
$container->uploadObjects(array(
    array('name' => 'index.html', 'path' => 'index.html'),
    array('name' => 'contact.html', 'path' => 'contact.html'),
    array('name' => 'error.html', 'path' => 'error.html'),
    array('name' => 'styles.css', 'path' => 'styles.css'),
    array('name' => 'main.js', 'path' => 'main.js'),
));
  1. Tell Cloud Files what to use for your default index page like this:
$container->setStaticIndexPage('index.html');
  1. (Optional) Tell Cloud Files which error page to use by default:
$container->setStaticErrorPage('error.html');

Bear in mind that steps 3 & 4 do not upload content, but rather specify a reference to an existing page/CloudFiles object.