Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.
I have access to the php-opencloud lib but it doesn't matter to me if I use it for this or not. I've found many examples of generating temp URLs for files stored in a container but all of them seem to be outdated (the most recent I found is from 4 years ago). I've tried them all with no luck.
This example does exactly what I'm trying to do but apparently the API has changed since it was written. Can anyone correct it for me to run under the current version of php-opencloud, or provide a straight Rackspace API version? Additionally, I'm *slightly* confused as to what the $connection variable is -- $connection = new Rackspace?? I tried that but the whole thing died with "no method" errors out the wazoo..
// connect to Cloud Files$objstore = $connection->ObjectStore('cloudFiles', 'DFW');
// Set a secretdefine('TEMP_URL_SECRET', 'This is my secret');$objstore->SetTempUrlSecret(TEMP_URL_SECRET);
// Put the container and file names$mycontainer = $objstore->Container('CdnContainer');$object = $mycontainer->DataObject('FOOBAR');
// Create the temp url$tempurl = $object->TempUrl(TEMP_URL_SECRET, 20, 'GET');
// Print stuff for testingprintf("Filename: %s\n", $object->Name());printf("CDN URL: %s\n", $object->PublicURL());printf("TEMP URL: %s\n", $tempurl);
Well, I played around long enough and got it figured out. Corrected code for the API as of 2/13/2018 below
$client= new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array( 'username' => 'username', 'apiKey' => 'apikey',));
$service = $client->objectStoreService('cloudFiles', 'ORD');
$account = $service->getAccount();$account->setTempUrlSecret('whatever_you_want');
// Put the container and file names$mycontainer = $service->getContainer('YourcontainerName');$object = $mycontainer->getObject('YourFileName');
// Create the temp url (60 seconds expiration)$tempurl = $object->getTemporaryUrl(60, 'GET');
printf("TEMP URL: %s\n", $tempurl);
mvincent Glad you were able to get it going. If you have a similar question in the future, you may get a faster response via a support ticket.
Brian KCloud Virt Engineer II, RHCVA, CCNARackspace Support