This topic lists some examples of using the
Zend_Service_WindowsAzure_Storage_Blob class. Other features are
available in the download package, as well as a detailed API
documentation of those features.
Using the following code, a blob storage container can be created on development storage.
Example 869. Creating a storage container
<?php
$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
$result = $storageClient->createContainer('testcontainer');
echo 'Container name is: ' . $result->Name;
Using the following code, a blob storage container can be removed from development storage.
Example 870. Deleting a storage container
<?php
$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
$storageClient->deleteContainer('testcontainer');
Using the following code, a blob can be uploaded to a blob storage container on development storage. Note that the container has already been created before.
Example 871. Storing a blob
<?php
$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
// upload /home/maarten/example.txt to Azure
$result = $storageClient->putBlob(
'testcontainer', 'example.txt', '/home/maarten/example.txt'
);
echo 'Blob name is: ' . $result->Name;
Using the following code, a blob can be copied from inside the storage account. The advantage of using this method is that the copy operation occurs in the Azure cloud and does not involve downloading the blob. Note that the container has already been created before.
Example 872. Copying a blob
<?php
$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
// copy example.txt to example2.txt
$result = $storageClient->copyBlob(
'testcontainer', 'example.txt', 'testcontainer', 'example2.txt'
);
echo 'Copied blob name is: ' . $result->Name;
Using the following code, a blob can be downloaded from a blob storage container on development storage. Note that the container has already been created before and a blob has been uploaded.
Example 873. Downloading a blob
<?php
$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
// download file to /home/maarten/example.txt
$storageClient->getBlob(
'testcontainer', 'example.txt', '/home/maarten/example.txt'
);
By default, blob storage containers on Windows Azure are protected from public viewing. If any user on the Internet should have access to a blob container, its ACL can be set to public. Note that this applies to a complete container and not to a single blob!
Using the following code, blob storage container ACL can be set on development storage. Note that the container has already been created before.
Example 874. Making a blob publicly available
<?php
$storageClient = new Zend_Service_WindowsAzure_Storage_Blob();
// make container publicly available (enumerate all blobs and read blob data)
$storageClient->setContainerAcl('testcontainer', Zend_Service_WindowsAzure_Storage_Blob::ACL_PUBLIC_CONTAINER);




