Created
September 10, 2012 22:55
-
-
Save ChrisRisner/3694556 to your computer and use it in GitHub Desktop.
geodemo2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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