require_once "WindowsAzure/WindowsAzure.php"; require_once 'PHPUnit\autoload.php';
use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Common\ServiceException;
// Create Connection String $connectionString = "DefaultEndpointsProtocol=http;AccountName=[yourAccount];AccountKey=[yourKey]"; // Create blob REST proxy. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
<?php require_once "WindowsAzure/WindowsAzure.php"; require_once 'PHPUnit\autoload.php'; use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Common\ServiceException; // Create Connection String $connectionString = "DefaultEndpointsProtocol=http;AccountName=[yourAccount];AccountKey=[yourKey]"; // Create blob REST proxy. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); $createContainerOptions = new CreateContainerOptions(); $createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS); // Set container metadata $createContainerOptions->addMetaData("key1", "value1"); $createContainerOptions->addMetaData("key2", "value2"); try { // Create container. $blobRestProxy->createContainer("pictures", $createContainerOptions); $blobRestProxy->createContainer("movies", $createContainerOptions); echo "Container 'pictures' and 'movies' created. "; } catch(ServiceException $e){ // Handle exception based on error codes and messages. // Error codes and messages are here: // http://msdn.microsoft.com/en-us/library/windowsazure/dd179439.aspx $code = $e->getCode(); $error_message = $e->getMessage(); echo $code.": ".$error_message."<br />"; } $blobRestProxy = null; ?>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท