Skip to content

Instantly share code, notes, and snippets.

@ChrisRisner
Created September 10, 2012 22:55
Show Gist options
  • Save ChrisRisner/3694556 to your computer and use it in GitHub Desktop.
Save ChrisRisner/3694556 to your computer and use it in GitHub Desktop.
geodemo2
/** This method will create a test container for use in our client side code **/
/** Code from http://blogs.msdn.com/b/brian_swan/archive/2010/07/08/accessing-windows-azure-blob-storage-from-php.aspx **/
/** Note that we're defaulting the container name to 'test' **/
$app->match('/api/Location/AddTestContainer', function () use ($app){
$storageClient = new Microsoft_WindowsAzure_Storage_Blob('blob.core.windows.net', STORAGE_ACCOUNT_NAME, STORAGE_ACCOUNT_KEY);
try {
if($storageClient->isValidContainerName('test')) {
if(!$storageClient->containerExists('test')) {
$result = $storageClient->createContainer('test');
echo "<h2>Container created.</h2>";
//Set container to public (remove this to make it private)
$storageClient->setContainerAcl('test',
Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC);
}
else {
echo "<h2>That container already exists.</h2>";
}
}
else {
echo "<h2>That is not a valid container name.</h2>";
}
} catch (Exception $e) {
return new Response('', 500);
}
return new Response('', 201);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment