Skip to content

Commit

Permalink
source code copied from azure-storage-php for v1.5.3-blob release
Browse files Browse the repository at this point in the history
  • Loading branch information
vinjiang committed Oct 9, 2021
1 parent 2475330 commit 9aec3e1
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 16 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2021.09 - version 1.5.3
* Upgraded dependency for `azure-storage-common` to version 1.5.2.
* Resolved some interface inconsistency between `IBlob`/`BlobRestProxy`.
* Imported `Psr\Http\Message\StreamInterface` in `IBlob`.

2020.12 - version 1.5.2
* Resolved an issue where access condition does not work for large block blob uploads.
* Guzzle version is now updated to support both 6.x and 7.x.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Microsoft Azure Storage Blob PHP Client Library

This project provides a PHP client library that makes it easy to access Microsoft Azure Storage blob services. For documentation on how to host PHP applications on Microsoft Azure, please see the [Microsoft Azure PHP Developer Center](http://www.windowsazure.com/en-us/develop/php/).
This project provides a PHP client library that makes it easy to access Microsoft Azure Storage blob services. For documentation on how to host PHP applications on Microsoft Azure, please see the [Microsoft Azure PHP Developer Center](https://www.windowsazure.com/en-us/develop/php/).

[![Latest Stable Version](https://poser.pugx.org/microsoft/azure-storage-blob/v/stable)](https://packagist.org/packages/microsoft/azure-storage-blob)

Expand All @@ -17,7 +17,7 @@ This project provides a PHP client library that makes it easy to access Microsof
* create block and page blobs (from a stream or a string), work with blob blocks and pages, delete blobs
* work with blob properties, metadata, leases, snapshot a blob

Please check details on [API reference documents](http://azure.github.io/azure-storage-php).
Please check details on [API reference documents](https://azure.github.io/azure-storage-php).

# Getting Started
## Minimum Requirements
Expand Down Expand Up @@ -52,7 +52,7 @@ cd ./azure-storage-php
}
}
```
2. Download **[composer.phar](http://getcomposer.org/composer.phar)** in your project root.
2. Download **[composer.phar](https://getcomposer.org/composer.phar)** in your project root.

3. Open a command prompt and execute this in your project root

Expand Down Expand Up @@ -137,7 +137,7 @@ To use proxies during HTTP requests, set system variable `HTTP_PROXY` and the pr
### Error: Unable to get local issuer certificate
cURL can't verify the validity of Microsoft certificate when trying to issue a request call to Azure Storage Services. You must configure cURL to use a certificate when issuing https requests by the following steps:

1. Download the cacert.pem file from [cURL site](http://curl.haxx.se/docs/caextract.html).
1. Download the cacert.pem file from [cURL site](https://curl.haxx.se/docs/caextract.html).

2. Then either:
* Open your php.ini file and add the following line:
Expand All @@ -164,11 +164,11 @@ For now, Microsoft Azure Storage PHP client libraries share almost the same inte

# Need Help?

Be sure to check out the Microsoft Azure [Developer Forums on Stack Overflow](http://go.microsoft.com/fwlink/?LinkId=234489) and [github issues](https://github.com/Azure/azure-storage-php/issues) if you have trouble with the provided code.
Be sure to check out the Microsoft Azure [Developer Forums on Stack Overflow](https://go.microsoft.com/fwlink/?LinkId=234489) and [github issues](https://github.com/Azure/azure-storage-php/issues) if you have trouble with the provided code.

# Contribute Code or Provide Feedback

If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/).
If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](https://azure.github.io/guidelines/).
You can find more details for contributing in the [CONTRIBUTING.md](CONTRIBUTING.md).

If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-storage-php/issues) section of the project.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microsoft/azure-storage-blob",
"version": "1.5.2",
"version": "1.5.3",
"description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.",
"keywords": [ "php", "azure", "storage", "sdk", "blob" ],
"license": "MIT",
Expand Down
17 changes: 9 additions & 8 deletions src/Blob/BlobRestProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
use MicrosoftAzure\Storage\Common\Models\Range;
use MicrosoftAzure\Storage\Common\SharedAccessSignatureHelper;
use Psr\Http\Message\StreamInterface;
use GuzzleHttp\Psr7\Utils;

/**
* This class constructs HTTP requests and receive HTTP responses for blob
Expand Down Expand Up @@ -759,7 +760,7 @@ private function updatePageBlobPagesAsyncImpl(
get_class(new Range(0))
)
);
$body = Psr7\stream_for($content);
$body = Utils::streamFor($content);

$method = Resources::HTTP_PUT;
$headers = array();
Expand Down Expand Up @@ -1834,7 +1835,7 @@ public function createBlockBlobAsync(
$content,
Models\CreateBlockBlobOptions $options = null
) {
$body = Psr7\stream_for($content);
$body = Utils::streamFor($content);

//If the size of the stream is not seekable or larger than the single
//upload threshold then call concurrent upload. Otherwise call putBlob.
Expand Down Expand Up @@ -1915,7 +1916,7 @@ public function createPageBlobFromContentAsync(
$content,
Models\CreatePageBlobFromContentOptions $options = null
) {
$body = Psr7\stream_for($content);
$body = Utils::streamFor($content);
$self = $this;

if (is_null($options)) {
Expand Down Expand Up @@ -2417,7 +2418,7 @@ public function createBlobPagesAsync(
$content,
Models\CreateBlobPagesOptions $options = null
) {
$contentStream = Psr7\stream_for($content);
$contentStream = Utils::streamFor($content);
//because the content is at most 4MB long, can retrieve all the data
//here at once.
$body = $contentStream->getContents();
Expand Down Expand Up @@ -2516,7 +2517,7 @@ public function createBlobBlockAsync(
$postParams = array();
$queryParams = $this->createBlobBlockQueryParams($options, $blockId);
$path = $this->createPath($container, $blob);
$contentStream = Psr7\stream_for($content);
$contentStream = Utils::streamFor($content);
$body = $contentStream->getContents();

$options->setLocationMode(LocationMode::PRIMARY_ONLY);
Expand Down Expand Up @@ -2597,7 +2598,7 @@ public function appendBlockAsync(
$queryParams = array();
$path = $this->createPath($container, $blob);

$contentStream = Psr7\stream_for($content);
$contentStream = Utils::streamFor($content);
$length = $contentStream->getSize();
$body = $contentStream->getContents();

Expand Down Expand Up @@ -3791,7 +3792,7 @@ public function getBlobAsync(
);
});
}

/**
* Undeletes a blob.
*
Expand All @@ -3810,7 +3811,7 @@ public function undeleteBlob(
) {
$this->undeleteBlobAsync($container, $blob, $options)->wait();
}

/**
* Undeletes a blob.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Blob/Internal/BlobResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BlobResources extends Resources
{
// @codingStandardsIgnoreStart

const BLOB_SDK_VERSION = '1.5.2';
const BLOB_SDK_VERSION = '1.5.3';
const STORAGE_API_LATEST_VERSION = '2017-11-09';

// Error messages
Expand Down
77 changes: 77 additions & 0 deletions src/Blob/Internal/IBlob.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use MicrosoftAzure\Storage\Common\Models\ServiceOptions;
use MicrosoftAzure\Storage\Common\Models\ServiceProperties;
use MicrosoftAzure\Storage\Common\Models\Range;
use Psr\Http\Message\StreamInterface;

/**
* This interface has all REST APIs provided by Windows Azure for Blob service.
Expand Down Expand Up @@ -1126,6 +1127,82 @@ public function setBlobMetadataAsync(
BlobModels\BlobServiceOptions $options = null
);

/**
* Downloads a blob to a file, the result contains its metadata and
* properties. The result will not contain a stream pointing to the
* content of the file.
*
* @param string $path The path and name of the file
* @param string $container name of the container
* @param string $blob name of the blob
* @param BlobModels\GetBlobOptions $options optional parameters
*
* @return BlobModels\GetBlobResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179440.aspx
*/
public function saveBlobToFile(
$path,
$container,
$blob,
BlobModels\GetBlobOptions $options = null
);

/**
* Creates promise to download a blob to a file, the result contains its
* metadata and properties. The result will not contain a stream pointing
* to the content of the file.
*
* @param string $path The path and name of the file
* @param string $container name of the container
* @param string $blob name of the blob
* @param BlobModels\GetBlobOptions $options optional parameters
*
* @return \GuzzleHttp\Promise\PromiseInterface
* @throws \Exception
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179440.aspx
*/
public function saveBlobToFileAsync(
$path,
$container,
$blob,
BlobModels\GetBlobOptions $options = null
);

/**
* Undeletes a blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param BlobModels\UndeleteBlobOptions $options optional parameters
*
* @return void
*
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob
*/
public function undeleteBlob(
$container,
$blob,
BlobModels\UndeleteBlobOptions $options = null
);

/**
* Undeletes a blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param BlobModels\UndeleteBlobOptions $options optional parameters
*
* @return \GuzzleHttp\Promise\PromiseInterface
*
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob
*/
public function undeleteBlobAsync(
$container,
$blob,
BlobModels\UndeleteBlobOptions $options = null
);

/**
* Reads or downloads a blob from the system, including its metadata and
* properties.
Expand Down

0 comments on commit 9aec3e1

Please sign in to comment.