function InitializeStorage()
{
    if (USE_DEV_EMULATOR) {
        //Connect to the Storage Emulator
        $tableClient = new Microsoft_WindowsAzure_Storage_Table();
        $blobClient = new Microsoft_WindowsAzure_Storage_Blob();
        $queueClient = new Microsoft_WindowsAzure_Storage_Queue();
    } else {
        //Connect to Azure storage
        $tableClient = new Microsoft_WindowsAzure_Storage_Table(AZURE_TABLES_URL, AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY);
        $blobClient = new Microsoft_WindowsAzure_Storage_Blob(AZURE_BLOBS_URL, AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY);
        $queueClient = new Microsoft_WindowsAzure_Storage_Table(AZURE_QUEUES_URL, AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY);
    }
    //Create a table to store GuestBook Entries if it doesn't exist
    if (!$tableClient->tableExists(GB_TABLE_NAME)) {
        $result = $tableClient->createTable(GB_TABLE_NAME);
    }
    //Validate the blob container name
    if ($blobClient->isValidContainerName(GB_BLOB_CONTAINER)) {
        if (!$blobClient->containerExists(GB_BLOB_CONTAINER)) {
            //create it if it doesn't exist
            $result = $blobClient->createContainer(GB_BLOB_CONTAINER);
            //Make it public
            $blobClient->setContainerAcl(GB_BLOB_CONTAINER, Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC);
            $blobClient->registerStreamWrapper();
        }
    }
    //Create a queue to send thumbnail jobs to a worker process if it doesn't exist
    $queue = $queueClient->createQueueIfNotExists(GB_QUEUE_NAME);
    return array($tableClient, $blobClient, $queueClient);
}
示例#2
0
 /**
  * Creates bucket
  *
  * @param string $container_id
  * @param string $error
  * @return boolean
  */
 function create_container(&$container_id, &$error)
 {
     if (!$this->_init($error)) {
         return false;
     }
     try {
         $containers = $this->_client->listContainers();
     } catch (Exception $exception) {
         $error = sprintf('Unable to list containers (%s).', $exception->getMessage());
         return false;
     }
     if (in_array($this->_config['container'], (array) $containers)) {
         $error = sprintf('Container already exists: %s.', $this->_config['container']);
         return false;
     }
     try {
         $this->_client->createContainer($this->_config['container']);
         $this->_client->setContainerAcl($this->_config['container'], Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC_BLOB);
     } catch (Exception $exception) {
         $error = sprintf('Unable to create container: %s (%s)', $this->_config['container'], $exception->getMessage());
         return false;
     }
     return true;
 }
示例#3
0
 /**
  * Ensure storage has been initialized
  */
 protected function _ensureStorageInitialized()
 {
     if (!$this->_blobStorageClient->containerExists($this->_controlContainer)) {
         $this->_blobStorageClient->createContainer($this->_controlContainer);
     }
 }
<?php

require_once 'Microsoft/WindowsAzure/Storage/Blob.php';
$storageClient = new Microsoft_WindowsAzure_Storage_Blob();
$result = $storageClient->createContainer('testcontainer');
echo 'Il nome del container creato è : ' . $result->Name;
示例#5
0
         $gstorage->create_bucket($_POST['newGStorageBucket'], '');
         $jobvalues['GStorageBucket'] = $_POST['newGStorageBucket'];
         sleep(1);
         //creation take a moment
     } catch (Exception $e) {
         $backwpup_message .= __($e->getMessage(), 'backwpup') . '<br />';
     }
 }
 if (!empty($_POST['newmsazureContainer']) and !empty($_POST['msazureHost']) and !empty($_POST['msazureAccName']) and !empty($_POST['msazureKey'])) {
     //create new s3 bucket if needed
     if (!class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
         require_once dirname(__FILE__) . '/../libs/Microsoft/WindowsAzure/Storage/Blob.php';
     }
     try {
         $storageClient = new Microsoft_WindowsAzure_Storage_Blob($_POST['msazureHost'], $_POST['msazureAccName'], $_POST['msazureKey']);
         $result = $storageClient->createContainer($_POST['newmsazureContainer']);
         $jobvalues['msazureContainer'] = $result->Name;
     } catch (Exception $e) {
         $backwpup_message .= __($e->getMessage(), 'backwpup') . '<br />';
     }
 }
 if (!empty($_POST['rscUsername']) and !empty($_POST['rscAPIKey']) and !empty($_POST['newrscContainer'])) {
     //create new Rackspase Container if needed
     if (!class_exists('CF_Authentication')) {
         require_once dirname(__FILE__) . '/../libs/rackspace/cloudfiles.php';
     }
     try {
         $auth = new CF_Authentication($_POST['rscUsername'], $_POST['rscAPIKey']);
         if ($auth->authenticate()) {
             $conn = new CF_Connection($auth);
             $public_container = $conn->create_container($_POST['newrscContainer']);