Skip to content

Commit

Permalink
source code copied from azure-storage-php for v1.3.0-blob release
Browse files Browse the repository at this point in the history
  • Loading branch information
vinjiang committed Mar 26, 2019
1 parent 6a89f27 commit 6fcef8b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 36 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2019.03 - version 1.3.0
* Fixed a bug where blob name '0' cannot be created.
* Documentation refinement.
* `ListContainer` now can have ETag more robustly fetched from response header.

2018.08 - version 1.2.0

* Updated Azure Storage API version from 2016-05-31 to 2017-04-17.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microsoft/azure-storage-blob",
"version": "1.2.0",
"version": "1.3.0",
"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 All @@ -12,7 +12,7 @@
],
"require": {
"php": ">=5.6.0",
"microsoft/azure-storage-common": "~1.2.0"
"microsoft/azure-storage-common": "~1.3.0"
},
"autoload": {
"psr-4": {
Expand Down
41 changes: 14 additions & 27 deletions src/Blob/BlobRestProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,27 +347,21 @@ private function getCopyBlobSourceName(
*/
private function createPath($container, $blob = '')
{
if (empty($blob)) {
if (!empty($container)) {
return $container;
} else {
return '/' . $container;
}
} else {
$encodedBlob = urlencode($blob);
// Unencode the forward slashes to match what the server expects.
$encodedBlob = str_replace('%2F', '/', $encodedBlob);
// Unencode the backward slashes to match what the server expects.
$encodedBlob = str_replace('%5C', '/', $encodedBlob);
// Re-encode the spaces (encoded as space) to the % encoding.
$encodedBlob = str_replace('+', '%20', $encodedBlob);
// Empty container means accessing default container
if (empty($container)) {
return $encodedBlob;
} else {
return '/' . $container . '/' . $encodedBlob;
}
if (empty($blob) && ($blob != '0')) {
return empty($container) ? '/' : $container;
}
$encodedBlob = urlencode($blob);
// Unencode the forward slashes to match what the server expects.
$encodedBlob = str_replace('%2F', '/', $encodedBlob);
// Unencode the backward slashes to match what the server expects.
$encodedBlob = str_replace('%5C', '/', $encodedBlob);
// Re-encode the spaces (encoded as space) to the % encoding.
$encodedBlob = str_replace('+', '%20', $encodedBlob);
// Empty container means accessing default container
if (empty($container)) {
return $encodedBlob;
}
return '/' . $container . '/' . $encodedBlob;
}

/**
Expand Down Expand Up @@ -556,7 +550,6 @@ private function addOptionalRangeHeader(array $headers, $start, $end)
*/
private static function getStatusCodeOfLeaseAction($leaseAction)
{
$statusCode = Resources::EMPTY_STRING;
switch ($leaseAction) {
case LeaseMode::ACQUIRE_ACTION:
$statusCode = Resources::STATUS_CREATED;
Expand Down Expand Up @@ -885,7 +878,6 @@ public function createContainerAsync(
Validate::notNullOrEmpty($container, 'container');

$method = Resources::HTTP_PUT;
$headers = array();
$postParams = array();
$queryParams = array(Resources::QP_REST_TYPE => 'container');
$path = $this->createPath($container);
Expand Down Expand Up @@ -1097,7 +1089,6 @@ public function getContainerAclAsync(
$postParams = array();
$queryParams = array();
$path = $this->createPath($container);
$statusCode = Resources::STATUS_OK;

if (is_null($options)) {
$options = new BlobServiceOptions();
Expand Down Expand Up @@ -1691,7 +1682,6 @@ public function createAppendBlobAsync(
$postParams = array();
$queryParams = array();
$path = $this->createPath($container, $blob);
$statusCode = Resources::STATUS_CREATED;

if (is_null($options)) {
$options = new CreateBlobOptions();
Expand Down Expand Up @@ -2462,7 +2452,6 @@ public function createBlobBlockAsync(
$postParams = array();
$queryParams = $this->createBlobBlockQueryParams($options, $blockId);
$path = $this->createPath($container, $blob);
$statusCode = Resources::STATUS_CREATED;
$contentStream = Psr7\stream_for($content);
$body = $contentStream->getContents();

Expand Down Expand Up @@ -2543,7 +2532,6 @@ public function appendBlockAsync(
$postParams = array();
$queryParams = array();
$path = $this->createPath($container, $blob);
$statusCode = Resources::STATUS_CREATED;

$contentStream = Psr7\stream_for($content);
$length = $contentStream->getSize();
Expand Down Expand Up @@ -2744,7 +2732,6 @@ public function commitBlobBlocksAsync(
);

$method = Resources::HTTP_PUT;
$headers = array();
$postParams = array();
$queryParams = array();
$path = $this->createPath($container, $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.2.0';
const BLOB_SDK_VERSION = '1.3.0';
const STORAGE_API_LATEST_VERSION = '2017-04-17';

// Error messages
Expand Down
6 changes: 3 additions & 3 deletions src/Blob/Internal/IBlob.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function listBlobsAsync(
* a 512-byte boundary.
* @param BlobModels\CreatePageBlobOptions $options optional parameters
*
* @return BlobModels\CopyBlobResult
* @return BlobModels\PutBlobResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
*/
Expand Down Expand Up @@ -489,10 +489,10 @@ public function createAppendBlobAsync(
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param string $content content of the blob
* @param string|resource|StreamInterface $content content of the blob
* @param BlobModels\CreateBlockBlobOptions $options optional parameters
*
* @return BlobModels\CopyBlobResult
* @return BlobModels\PutBlobResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Blob/Models/GetBlobResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function setProperties(BlobProperties $properties)
/**
* Gets blob contentStream.
*
* @return \resource
* @return resource
*/
public function getContentStream()
{
Expand All @@ -123,7 +123,7 @@ public function getContentStream()
/**
* Sets blob contentStream.
*
* @param \resource $contentStream The stream handle.
* @param resource $contentStream The stream handle.
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Blob/Models/ListContainersResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function create(array $parsedResponse, $location = '')
$date = $value['Properties']['Last-Modified'];
$date = Utilities::rfc1123ToDateTime($date);
$properties->setLastModified($date);
$properties->setETag($value['Properties']['Etag']);
$properties->setETag(Utilities::tryGetValueInsensitive(Resources::ETAG, $value['Properties']));

if (array_key_exists('LeaseStatus', $value['Properties'])) {
$properties->setLeaseStatus($value['Properties']['LeaseStatus']);
Expand Down

0 comments on commit 6fcef8b

Please sign in to comment.