Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a working example. I used the same two functions mentioned in my link above.</p> <pre><code>&lt;?php require_once 'WindowsAzure/WindowsAzure.php'; use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Common\ServiceException; use WindowsAzure\Blob\Models\Block; use WindowsAzure\Blob\Models\BlobBlockType; define('CHUNK_SIZE', 1024*1024);//Block Size = 1 MB try { $connectionString = "UseDevelopmentStorage=true"; $instance = ServicesBuilder::getInstance(); $blobRestProxy = $instance -&gt; createBlobService($connectionString); $containerName = "mycontainer"; $blobName = "DSC01166.jpg"; $content = fopen("d:\DSC01166.jpg", "rb"); $index = 0; $continue = True; $counter = 1; $blockIds = array(); while (!feof($content)) { $blockId = str_pad($counter, 6, "0", STR_PAD_LEFT); $block = new Block(); $block -&gt; setBlockId(base64_encode($blockId)); $block -&gt; setType("Uncommitted"); array_push($blockIds, $block); echo $blockId . " | " . base64_encode($blockId) . " | " . count($blockIds); echo " \n "; echo " -----------------------------------------"; $data=fread($content, CHUNK_SIZE); echo "Read " . strlen($data) . " of data from file"; echo " \n "; echo " -----------------------------------------"; echo " \n "; echo " -----------------------------------------"; echo "Uploading block #: " . $blockId + " into blob storage. Please wait."; echo " -----------------------------------------"; echo " \n "; $blobRestProxy -&gt; createBlobBlock($containerName, $blobName, base64_encode($blockId), $data); echo "Uploaded block: " . $blockId . " into blob storage. Please wait"; echo " \n "; echo " -----------------------------------------"; echo " \n "; $counter = $counter + 1; } fclose($content); echo "Now committing block list. Please wait."; echo " -----------------------------------------"; echo " \n "; echo "hello"; $blobRestProxy -&gt; commitBlobBlocks($containerName, $blobName, $blockIds); echo " -----------------------------------------"; echo " \n "; echo "Blob created successfully."; } catch(Exception $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-&gt;getCode(); $error_message = $e-&gt;getMessage(); echo $code.": ".$error_message."&lt;br /&gt;"; } ?&gt; </code></pre> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload