Skip to content

Instantly share code, notes, and snippets.

@jpilcher
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpilcher/923b823a9c6816250c56 to your computer and use it in GitHub Desktop.
Save jpilcher/923b823a9c6816250c56 to your computer and use it in GitHub Desktop.
Shows how to create a temporary url to upload a file directly to a Rackspace container.
//http://docs.php-opencloud.com/en/latest/index.html
$client = new Rackspace(
Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => '{{username}}',
'apiKey' => '{{apiKey}}'
)
);
$objectStoreService = $client->objectStoreService(null, 'ORD', 'publicURL');
$container = $objectStoreService->getContainer('{{container_name}}');
//update the container headers for CORS
$container->saveMetadata(array(
'Access-Control-Allow-Origin' => '{{your_domain}}'
));
$object = $container->dataObject();
$object->setName("{{filename}}"); //probably a GUID
$url = $object->getTemporaryUrl(3000, "PUT");
//give url to the client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment