Azure Storage Blob Models Sample in PHP

This sample demonstrates making a use of models provided by Microsoft Azure Storage SDK for PHP. Generally, this sample contains two main parts, one demonstrates how to use models during creating options of containers and block blobs, and the other part demonstrates how to use models during getting containers, blobs and their properties and contents.

Note

This sample contains an Angular SPA as the client part and one PHP script for all the requests from client, for keeping the pure PHP code of usage of models provided by Azure Storage SDK for PHP.

Preparation

  1. An Azure Storage Account
  2. PHP 5.5 or above
  3. Composer manage PHP dependencies and npm manage the dependencies for client side
  4. Gulp manage client scripts

Creation

We will follow the steps to create a container, upload a text file to this container devided into several block blobs, then will upload a video file to this container in chunks. After the creation, we can start the other part of trial.

Step 1. Create trial container

During this step, we will create a trial container, and set the Public Access and custom the metadata via MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions.

Step 2. Create trial text block blobs

During this step, we will upload a markdown text file to the container created preview, set a contentType property and custom the metadata via MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions, and divid the file into several small block blobs for the later trial.

Step 3. Create trial video block blobs

During this step, we will upload a video file to the container created preview. It will be divided into MicrosoftAzure\Storage\Blob\Models\Block, then will be set a contentType property and custom the metadata via MicrosoftAzure\Storage\Blob\Models\CommitBlobBlocksOptions.