WindowsAzure/azure-sdk-for-php — pull request #652 by beberlei (2013-02-18 21:37:09+00:00)
Title: Add Stream API for Blobs

PHP offers a stream API that allows operations on services to look like low-level php filesystem operations.

This pull request adds support for this stream API for Windows Azure Blob Storage. The code was ported from the old SDK into the AzureDistributionBundle and from there now to this SDK.

This functionality is highly interesting for the SDK, because it has a wide range of use-cases with existing libraries that operate on PHP filesystem streams.

Example:

$fileName = 'azure://my_container/test.txt';

$blobClient = $this->createBlobClient();

$fh = fopen($fileName, 'w');
fwrite($fh, "Hello world!");
$pos = ftell($fh);
fseek($fh, 0);
fwrite($fh, "Hello world!");
fclose($fh);

$result = file_get_contents($fileName);

$this->assertEquals('Hello world!', $result);
$this->assertEquals(12, $pos);
The Pull Request comes with 17 functional tests that are passing.