FileUpload Azure Php

Mar 21, 2013 at 10:18 AM
Hi I am wajih

That's my first time to deal with azure i have done configuration my Senerio is that
  1. upload file from browser to php
  2. php puts file in blob
  3. puts blob refrence in queue
So first upload file from browser that thing i have done for remaning two i have written this code please tell is there any mistake so correct my code.

here code given below

require_once "vendor/autoload.php";
require_once "AzureBlobPhpUploader/bookMessage.php";

use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
use WindowsAzure\ServiceBus\Models\QueueInfo;
use WindowsAzure\Queue\QueueRestProxy;
use WindowsAzure\Queue\Models\CreateQueueOptions;
use WindowsAzure\Queue\Models\CreateMessageOptions;
use WindowsAzure\ServiceBus\models\BrokeredMessage;;

class fileLoaderForProcess
public static function uploadFile($filePath)
    // Create blob REST proxy.
    $connectionString = "";
    $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
    $createContainerOptions = new CreateContainerOptions();

    // Set public access policy. Possible values are
    // PublicAccessType::CONTAINER_AND_BLOBS and PublicAccessType::BLOBS_ONLY.
    // CONTAINER_AND_BLOBS: full public read access for container and blob data.
    // BLOBS_ONLY: public read access for blobs. Container data not available.
    // If this value is not specified, container data is private to the account owner.

    $msg = new BookMessage();
    $getUniqueId = uniqid();
    $bookGuid = $msg->getBookguid();
    $blobRefrence = $msg->getBlobReference();

//  $message = new BrokeredMessage();
//  $message->setBody($msg);

    try {
        // Create container.
        $blobRestProxy->createContainer("books", $createContainerOptions);
        $content = fopen($filePath, "r");
        $blob_name = "pdfFile";

        $blobref = $blobRestProxy->createBlockBlob("books", $blob_name, $content);

        // Create Service Bus REST proxy.
        $createQueueOptions = new CreateQueueOptions();
        $messageQueue = $queueRestProxy->createQueue("booksQueue", $createQueueOptions);
        $queueRestProxy->createMessage($messageQueue, $msg);

    } catch(ServiceException $e){
        $code = $e->getCode();
        $error_message = $e->getMessage();
        echo $code.": ".$error_message."<br />";

Mar 21, 2013 at 10:23 AM
This SDK has been deprecated in favor of the SDK released by Windows Azure at . As the Windows Azure API evolves this CodePlex project code will stop working. Please try using the new SDK and post an issue on Github if you have issues there also.

Another great resource is
Mar 21, 2013 at 10:28 AM
can you get rid out of from or can u correct my code.