lib/Beberlei/AzureBlobStorage/BlobClient.php
public function putLargeBlob($containerName = '', $blobName = '', $localFileName = '', $metadata = array(), $leaseId = null, $additionalHeaders = array())
    {
        Assertion::notEmpty($containerName, 'Container name is not specified');
        self::assertValidContainerName($containerName);
        Assertion::notEmpty($blobName, 'Blob name is not specified.');
        Assertion::notEmpty($localFileName, 'Local file name is not specified.');
        Assertion::file($localFileName, 'Local file name is not specified.');
        self::assertValidRootContainerBlobName($containerName, $blobName);

        if (filesize($localFileName) < self::MAX_BLOB_SIZE) {
            return $this->putBlob($containerName, $blobName, $localFileName, $metadata, $leaseId, $additionalHeaders);
        }

        $numberOfParts = ceil( filesize($localFileName) / self::MAX_BLOB_TRANSFER_SIZE );

        $blockIdentifiers = array();
        for ($i = 0; $i < $numberOfParts; $i++) {
            $blockIdentifiers[] = $this->generateBlockId($i);
        }

        $fp = fopen($localFileName, 'r');
        if ($fp === false) {
            throw new BlobException('Could not open local file.');
        }

        for ($i = 0; $i < $numberOfParts; $i++) {
            fseek($fp, $i * self::MAX_BLOB_TRANSFER_SIZE);

            $fileContents = fread($fp, self::MAX_BLOB_TRANSFER_SIZE);

            $this->putBlock($containerName, $blobName, $blockIdentifiers[$i], $fileContents, $leaseId);

            $fileContents = null;
            unset($fileContents);
        }

        fclose($fp);

        $this->putBlockList($containerName, $blobName, $blockIdentifiers, $metadata, $leaseId, $additionalHeaders);

        return $this->getBlobInstance($containerName, $blobName, null, $leaseId);
    }
public function putLargeBlob($containerName = '', $blobName = '', $localFileName = '', $metadata = array(), $leaseId = null, $additionalHeaders = array())
    {
        Assertion::notEmpty($containerName, 'Container name is not specified');
        self::assertValidContainerName($containerName);
        Assertion::notEmpty($blobName, 'Blob name is not specified.');
        Assertion::notEmpty($localFileName, 'Local file name is not specified.');
        Assertion::file($localFileName, 'Local file name is not specified.');
        self::assertValidRootContainerBlobName($containerName, $blobName);

        if (filesize($localFileName) < self::MAX_BLOB_SIZE) {
            return $this->putBlob($containerName, $blobName, $localFileName, $metadata, $leaseId, $additionalHeaders);
        }

        $numberOfParts = ceil( filesize($localFileName) / self::MAX_BLOB_TRANSFER_SIZE );

        $blockIdentifiers = array();
        for ($i = 0; $i < $numberOfParts; $i++) {
            $blockIdentifiers[] = $this->generateBlockId($i);
        }

        $fp = fopen($localFileName, 'r');
        if ($fp === false) {
            throw new BlobException('Could not open local file.');
        }

        for ($i = 0; $i < $numberOfParts; $i++) {
            fseek($fp, $i * self::MAX_BLOB_TRANSFER_SIZE);

            $fileContents = fread($fp, self::MAX_BLOB_TRANSFER_SIZE);

            $this->putBlock($containerName, $blobName, $blockIdentifiers[$i], $fileContents, $leaseId);

            $fileContents = null;
            unset($fileContents);
        }

        fclose($fp);

        $this->putBlockList($containerName, $blobName, $blockIdentifiers, $metadata, $leaseId, $additionalHeaders);

        return $this->getBlobInstance($containerName, $blobName, null, $leaseId);
    }
Put large blob (> 64 MB)

@param string $containerName Container name
@param string $blobName Blob name
@param string $localFileName Local file name to be uploaded
@param array  $metadata      Key/value pairs of meta data
@param string $leaseId       Lease identifier
@param array  $additionalHeaders  Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
@return object Partial blob properties
@throws BlobException