Skip to content

Commit 6fcef8b

Browse files
committed
source code copied from azure-storage-php for v1.3.0-blob release
1 parent 6a89f27 commit 6fcef8b

File tree

7 files changed

+28
-36
lines changed

7 files changed

+28
-36
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019.03 - version 1.3.0
2+
* Fixed a bug where blob name '0' cannot be created.
3+
* Documentation refinement.
4+
* `ListContainer` now can have ETag more robustly fetched from response header.
5+
16
2018.08 - version 1.2.0
27

38
* Updated Azure Storage API version from 2016-05-31 to 2017-04-17.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "microsoft/azure-storage-blob",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.",
55
"keywords": [ "php", "azure", "storage", "sdk", "blob" ],
66
"license": "MIT",
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": ">=5.6.0",
15-
"microsoft/azure-storage-common": "~1.2.0"
15+
"microsoft/azure-storage-common": "~1.3.0"
1616
},
1717
"autoload": {
1818
"psr-4": {

src/Blob/BlobRestProxy.php

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -347,27 +347,21 @@ private function getCopyBlobSourceName(
347347
*/
348348
private function createPath($container, $blob = '')
349349
{
350-
if (empty($blob)) {
351-
if (!empty($container)) {
352-
return $container;
353-
} else {
354-
return '/' . $container;
355-
}
356-
} else {
357-
$encodedBlob = urlencode($blob);
358-
// Unencode the forward slashes to match what the server expects.
359-
$encodedBlob = str_replace('%2F', '/', $encodedBlob);
360-
// Unencode the backward slashes to match what the server expects.
361-
$encodedBlob = str_replace('%5C', '/', $encodedBlob);
362-
// Re-encode the spaces (encoded as space) to the % encoding.
363-
$encodedBlob = str_replace('+', '%20', $encodedBlob);
364-
// Empty container means accessing default container
365-
if (empty($container)) {
366-
return $encodedBlob;
367-
} else {
368-
return '/' . $container . '/' . $encodedBlob;
369-
}
350+
if (empty($blob) && ($blob != '0')) {
351+
return empty($container) ? '/' : $container;
352+
}
353+
$encodedBlob = urlencode($blob);
354+
// Unencode the forward slashes to match what the server expects.
355+
$encodedBlob = str_replace('%2F', '/', $encodedBlob);
356+
// Unencode the backward slashes to match what the server expects.
357+
$encodedBlob = str_replace('%5C', '/', $encodedBlob);
358+
// Re-encode the spaces (encoded as space) to the % encoding.
359+
$encodedBlob = str_replace('+', '%20', $encodedBlob);
360+
// Empty container means accessing default container
361+
if (empty($container)) {
362+
return $encodedBlob;
370363
}
364+
return '/' . $container . '/' . $encodedBlob;
371365
}
372366

373367
/**
@@ -556,7 +550,6 @@ private function addOptionalRangeHeader(array $headers, $start, $end)
556550
*/
557551
private static function getStatusCodeOfLeaseAction($leaseAction)
558552
{
559-
$statusCode = Resources::EMPTY_STRING;
560553
switch ($leaseAction) {
561554
case LeaseMode::ACQUIRE_ACTION:
562555
$statusCode = Resources::STATUS_CREATED;
@@ -885,7 +878,6 @@ public function createContainerAsync(
885878
Validate::notNullOrEmpty($container, 'container');
886879

887880
$method = Resources::HTTP_PUT;
888-
$headers = array();
889881
$postParams = array();
890882
$queryParams = array(Resources::QP_REST_TYPE => 'container');
891883
$path = $this->createPath($container);
@@ -1097,7 +1089,6 @@ public function getContainerAclAsync(
10971089
$postParams = array();
10981090
$queryParams = array();
10991091
$path = $this->createPath($container);
1100-
$statusCode = Resources::STATUS_OK;
11011092

11021093
if (is_null($options)) {
11031094
$options = new BlobServiceOptions();
@@ -1691,7 +1682,6 @@ public function createAppendBlobAsync(
16911682
$postParams = array();
16921683
$queryParams = array();
16931684
$path = $this->createPath($container, $blob);
1694-
$statusCode = Resources::STATUS_CREATED;
16951685

16961686
if (is_null($options)) {
16971687
$options = new CreateBlobOptions();
@@ -2462,7 +2452,6 @@ public function createBlobBlockAsync(
24622452
$postParams = array();
24632453
$queryParams = $this->createBlobBlockQueryParams($options, $blockId);
24642454
$path = $this->createPath($container, $blob);
2465-
$statusCode = Resources::STATUS_CREATED;
24662455
$contentStream = Psr7\stream_for($content);
24672456
$body = $contentStream->getContents();
24682457

@@ -2543,7 +2532,6 @@ public function appendBlockAsync(
25432532
$postParams = array();
25442533
$queryParams = array();
25452534
$path = $this->createPath($container, $blob);
2546-
$statusCode = Resources::STATUS_CREATED;
25472535

25482536
$contentStream = Psr7\stream_for($content);
25492537
$length = $contentStream->getSize();
@@ -2744,7 +2732,6 @@ public function commitBlobBlocksAsync(
27442732
);
27452733

27462734
$method = Resources::HTTP_PUT;
2747-
$headers = array();
27482735
$postParams = array();
27492736
$queryParams = array();
27502737
$path = $this->createPath($container, $blob);

src/Blob/Internal/BlobResources.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BlobResources extends Resources
4141
{
4242
// @codingStandardsIgnoreStart
4343

44-
const BLOB_SDK_VERSION = '1.2.0';
44+
const BLOB_SDK_VERSION = '1.3.0';
4545
const STORAGE_API_LATEST_VERSION = '2017-04-17';
4646

4747
// Error messages

src/Blob/Internal/IBlob.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public function listBlobsAsync(
407407
* a 512-byte boundary.
408408
* @param BlobModels\CreatePageBlobOptions $options optional parameters
409409
*
410-
* @return BlobModels\CopyBlobResult
410+
* @return BlobModels\PutBlobResult
411411
*
412412
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
413413
*/
@@ -489,10 +489,10 @@ public function createAppendBlobAsync(
489489
*
490490
* @param string $container name of the container
491491
* @param string $blob name of the blob
492-
* @param string $content content of the blob
492+
* @param string|resource|StreamInterface $content content of the blob
493493
* @param BlobModels\CreateBlockBlobOptions $options optional parameters
494494
*
495-
* @return BlobModels\CopyBlobResult
495+
* @return BlobModels\PutBlobResult
496496
*
497497
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
498498
*/

src/Blob/Models/GetBlobResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function setProperties(BlobProperties $properties)
113113
/**
114114
* Gets blob contentStream.
115115
*
116-
* @return \resource
116+
* @return resource
117117
*/
118118
public function getContentStream()
119119
{
@@ -123,7 +123,7 @@ public function getContentStream()
123123
/**
124124
* Sets blob contentStream.
125125
*
126-
* @param \resource $contentStream The stream handle.
126+
* @param resource $contentStream The stream handle.
127127
*
128128
* @return void
129129
*/

src/Blob/Models/ListContainersResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static function create(array $parsedResponse, $location = '')
115115
$date = $value['Properties']['Last-Modified'];
116116
$date = Utilities::rfc1123ToDateTime($date);
117117
$properties->setLastModified($date);
118-
$properties->setETag($value['Properties']['Etag']);
118+
$properties->setETag(Utilities::tryGetValueInsensitive(Resources::ETAG, $value['Properties']));
119119

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

0 commit comments

Comments
 (0)