* @category Microsoft * @package MicrosoftAzure\Storage\Samples * @author Azure Storage PHP SDK <*****@*****.**> * @copyright 2016 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ namespace MicrosoftAzure\Storage\Samples; require_once "../vendor/autoload.php"; use MicrosoftAzure\Storage\Common\ServicesBuilder; use MicrosoftAzure\Storage\Common\ServiceException; use MicrosoftAzure\Storage\Queue\Models\CreateQueueOptions; use MicrosoftAzure\Storage\Queue\Models\PeekMessagesOptions; $connectionString = 'DefaultEndpointsProtocol=https;AccountName=<yourAccount>;AccountKey=<yourKey>'; $queueClient = ServicesBuilder::getInstance()->createQueueService($connectionString); // A QueueRestProxy object lets you create a queue with the createQueue method. When creating a queue, // you can set options on the queue, but doing so is not required. createQueueSample($queueClient); // To add a message to a queue, use QueueRestProxy->createMessage. The method takes the queue name, // the message text, and message options (which are optional). For compatibility with others you may // need to base64 encode message. addMessageToQueueSample($queueClient); // You can peek at a message (or messages) at the front of a queue without removing it from the queue // by calling QueueRestProxy->peekMessages. peekNextMessageSample($queueClient); // Your code removes a message from a queue in two steps. First, you call QueueRestProxy->listMessages, // which makes the message invisible to any other code reading from the queue. By default, this message // will stay invisible for 30 seconds (if the message is not deleted in this time period, it will become // visible on the queue again). To finish removing the message from the queue, you must call // QueueRestProxy->deleteMessage.
/** * @param BlobRestProxy $blobRestProxy * @throws \TYPO3\CMS\Core\Exception */ public function initialize(BlobRestProxy $blobRestProxy = null) { if ($blobRestProxy === null) { try { $this->blobRestProxy = ServicesBuilder::getInstance()->createBlobService($this->constructConnectionString()); } catch (\Exception $e) { $flashMessage = $this->getFlashMessageService()->getFlashMessageInstance($e->getMessage(), 'Error!', FlashMessage::ERROR); $this->getMessageQueueByIdentifier()->enqueue($flashMessage); } } else { $this->blobRestProxy = $blobRestProxy; } if ($this->processConfiguration()) { $this->createContainer(); $this->capabilities = ResourceStorage::CAPABILITY_BROWSABLE | ResourceStorage::CAPABILITY_PUBLIC | ResourceStorage::CAPABILITY_WRITABLE; } }
* @category Microsoft * @package MicrosoftAzure\Storage\Samples * @author Azure Storage PHP SDK <*****@*****.**> * @copyright 2016 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ namespace MicrosoftAzure\Storage\Samples; require_once "../vendor/autoload.php"; use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions; use MicrosoftAzure\Storage\Blob\Models\PublicAccessType; use MicrosoftAzure\Storage\Common\ServicesBuilder; use MicrosoftAzure\Storage\Common\ServiceException; $connectionString = 'DefaultEndpointsProtocol=https;AccountName=<yourAccount>;AccountKey=<yourKey>'; $blobClient = ServicesBuilder::getInstance()->createBlobService($connectionString); // To create a container call createContainer. createContainerSample($blobClient); // To upload a file as a blob, use the BlobRestProxy->createBlockBlob method. This operation will // create the blob if it doesn¡¯t exist, or overwrite it if it does. The code example below assumes // that the container has already been created and uses fopen to open the file as a stream. uploadBlobSample($blobClient); // To download blob into a file, use the BlobRestProxy->getBlob method. The example below assumes // the blob to download has been already created. downloadBlobSample($blobClient); // To list the blobs in a container, use the BlobRestProxy->listBlobs method with a foreach loop to loop // through the result. The following code outputs the name and URI of each blob in a container. listBlobsSample($blobClient); function createContainerSample($blobClient) { // OPTIONAL: Set public access policy and metadata.
* @package MicrosoftAzure\Storage\Samples * @author Azure Storage PHP SDK <*****@*****.**> * @copyright 2016 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ namespace MicrosoftAzure\Storage\Samples; require_once "../vendor/autoload.php"; use MicrosoftAzure\Storage\Common\ServicesBuilder; use MicrosoftAzure\Storage\Common\ServiceException; use MicrosoftAzure\Storage\Table\Models\BatchOperations; use MicrosoftAzure\Storage\Table\Models\Entity; use MicrosoftAzure\Storage\Table\Models\EdmType; $connectionString = 'DefaultEndpointsProtocol=https;AccountName=<yourAccount>;AccountKey=<yourKey>'; $tableClient = ServicesBuilder::getInstance()->createTableService($connectionString); // To create a table call createTable. createTableSample($tableClient); // To add an entity to a table, create a new Entity object and pass it to TableRestProxy->insertEntity. // Note that when you create an entity you must specify a PartitionKey and RowKey. These are the unique // identifiers for an entity and are values that can be queried much faster than other entity properties. // The system uses PartitionKey to automatically distribute the table¡¯s entities over many storage nodes. insertEntitySample($tableClient); // To add mutiple entities with one call, create a BatchOperations and pass it to TableRestProxy->batch. // Note that all these entities must have the same PartitionKey value. BatchOperations supports to update, // merge, delete entities as well. You can find more details in: // https://msdn.microsoft.com/library/azure/dd894038.aspx batchInsertEntitiesSample($tableClient); // To query for entities you can call queryEntities. The subset of entities you retrieve will be determined // by the filter you use (for more information, see Querying Tables and Entities): // https://msdn.microsoft.com/library/azure/dd894031.aspx
/** * Builds a table object. * * @param string $connectionString The configuration connection string. * * @return WindowsAzure\Table\Internal\ITable */ public function createTableService($connectionString) { return StorageServiceBuilder::getInstance()->createTableService($connectionString); }
/** * @covers MicrosoftAzure\Storage\Common\ServicesBuilder::getInstance */ public function testGetInstance() { // Test $actual = ServicesBuilder::getInstance(); // Assert $this->assertInstanceOf('MicrosoftAzure\\Storage\\Common\\ServicesBuilder', $actual); }
/** * {@inheritdoc} */ public function create() { return ServicesBuilder::getInstance()->createBlobService($this->connectionString); }