Skip to content

Commit 6a333cd

Browse files
committed
source code copied from azure-storage-php for v1.5.0-blob release
1 parent 8310c2e commit 6a333cd

File tree

8 files changed

+250
-9
lines changed

8 files changed

+250
-9
lines changed

ChangeLog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
2020.01 - version 1.5.0
2+
3+
* Added support to include deleted in blob list.
4+
* Added support to undelete a blob.
5+
* Fixed the issue in SAS token where special characters were not correctly encoded.
6+
* Samples no longer uses ‘BlobRestProxy’ directly, instead, ‘ServicesBuilder’ is used.
7+
18
2019.04 - version 1.4.0
9+
210
* Added support for OAuth authentication.
311
* Resolved some issues on Linux platform.
412

513
2019.03 - version 1.3.0
14+
615
* Fixed a bug where blob name '0' cannot be created.
716
* Documentation refinement.
817
* `ListContainer` now can have ETag more robustly fetched from response header.
@@ -31,4 +40,4 @@
3140
* Removed `dataSerializer` parameter from `BlobRestProxy` constructor.
3241
* Added `setUseTransactionalMD5` method for options of `BlobRestProxy::CreateBlockBlob` and `BlobRestProxy::CreatePageBlobFromContent`. Default false, enabling transactional MD5 validation will take more cpu and memory resources.
3342
* Fixed a bug that CopyBlobFromURLOptions not found.
34-
* Deprecated PHP 5.5 support.
43+
* Deprecated PHP 5.5 support.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "microsoft/azure-storage-blob",
3-
"version": "1.4.0",
3+
"version": "1.5.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",

src/Blob/BlobRestProxy.php

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use MicrosoftAzure\Storage\Blob\Models\CreateBlobSnapshotResult;
4747
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
4848
use MicrosoftAzure\Storage\Blob\Models\CreatePageBlobOptions;
49+
use MicrosoftAzure\Storage\Blob\Models\UndeleteBlobOptions;
4950
use MicrosoftAzure\Storage\Blob\Models\DeleteBlobOptions;
5051
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataOptions;
5152
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataResult;
@@ -1544,13 +1545,15 @@ public function listBlobsAsync(
15441545
$includeSnapshots = $options->getIncludeSnapshots();
15451546
$includeUncommittedBlobs = $options->getIncludeUncommittedBlobs();
15461547
$includecopy = $options->getIncludeCopy();
1548+
$includeDeleted = $options->getIncludeDeleted();
15471549

15481550
$includeValue = static::groupQueryValues(
15491551
array(
15501552
$includeMetadata ? 'metadata' : null,
15511553
$includeSnapshots ? 'snapshots' : null,
15521554
$includeUncommittedBlobs ? 'uncommittedblobs' : null,
1553-
$includecopy ? 'copy' : null
1555+
$includecopy ? 'copy' : null,
1556+
$includeDeleted ? 'deleted' : null,
15541557
)
15551558
);
15561559

@@ -3788,6 +3791,84 @@ public function getBlobAsync(
37883791
);
37893792
});
37903793
}
3794+
3795+
/**
3796+
* Undeletes a blob.
3797+
*
3798+
* @param string $container name of the container
3799+
* @param string $blob name of the blob
3800+
* @param Models\UndeleteBlobOptions $options optional parameters
3801+
*
3802+
* @return void
3803+
*
3804+
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob
3805+
*/
3806+
public function undeleteBlob(
3807+
$container,
3808+
$blob,
3809+
Models\UndeleteBlobOptions $options = null
3810+
) {
3811+
$this->undeleteBlobAsync($container, $blob, $options)->wait();
3812+
}
3813+
3814+
/**
3815+
* Undeletes a blob.
3816+
*
3817+
* @param string $container name of the container
3818+
* @param string $blob name of the blob
3819+
* @param Models\UndeleteBlobOptions $options optional parameters
3820+
*
3821+
* @return \GuzzleHttp\Promise\PromiseInterface
3822+
*
3823+
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/undelete-blob
3824+
*/
3825+
public function undeleteBlobAsync(
3826+
$container,
3827+
$blob,
3828+
Models\UndeleteBlobOptions $options = null
3829+
) {
3830+
Validate::canCastAsString($container, 'container');
3831+
Validate::canCastAsString($blob, 'blob');
3832+
Validate::notNullOrEmpty($blob, 'blob');
3833+
3834+
$method = Resources::HTTP_PUT;
3835+
$headers = array();
3836+
$postParams = array();
3837+
$queryParams = array();
3838+
$path = $this->createPath($container, $blob);
3839+
3840+
if (is_null($options)) {
3841+
$options = new UndeleteBlobOptions();
3842+
}
3843+
3844+
$leaseId = $options->getLeaseId();
3845+
3846+
$headers = $this->addOptionalAccessConditionHeader(
3847+
$headers,
3848+
$options->getAccessConditions()
3849+
);
3850+
3851+
$this->addOptionalHeader(
3852+
$headers,
3853+
Resources::X_MS_LEASE_ID,
3854+
$leaseId
3855+
);
3856+
3857+
$this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'undelete');
3858+
3859+
$options->setLocationMode(LocationMode::PRIMARY_ONLY);
3860+
3861+
return $this->sendAsync(
3862+
$method,
3863+
$headers,
3864+
$queryParams,
3865+
$postParams,
3866+
$path,
3867+
Resources::STATUS_OK,
3868+
Resources::EMPTY_STRING,
3869+
$options
3870+
);
3871+
}
37913872

37923873
/**
37933874
* Deletes a blob or blob snapshot.

src/Blob/BlobSharedAccessSignatureHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function generateBlobServiceSharedAccessSignatureToken(
180180
$parameters[] = $contentType;
181181

182182
// implode the parameters into a string
183-
$stringToSign = utf8_encode(implode("\n", $parameters));
183+
$stringToSign = implode("\n", $parameters);
184184
// decode the account key from base64
185185
$decodedAccountKey = base64_decode($this->accountKey);
186186
// create the signature with hmac sha256

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.4.0';
44+
const BLOB_SDK_VERSION = '1.5.0';
4545
const STORAGE_API_LATEST_VERSION = '2017-11-09';
4646

4747
// Error messages

src/Blob/Models/BlobProperties.php

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
class BlobProperties
4242
{
4343
private $lastModified;
44+
private $creationTime;
4445
private $etag;
4546
private $contentType;
4647
private $contentLength;
@@ -65,6 +66,8 @@ class BlobProperties
6566
private $accessTierInferred;
6667
private $accessTierChangeTime;
6768
private $archiveStatus;
69+
private $deletedTime;
70+
private $remainingRetentionDays;
6871

6972
/**
7073
* Creates BlobProperties object from $parsed response in array representation of XML elements
@@ -104,16 +107,33 @@ public static function createFromXml(array $parsed)
104107
)
105108
);
106109

107-
$date = Utilities::tryGetValue($clean, 'accesstierchangetime');
108-
if (!is_null($date)) {
109-
$date = Utilities::rfc1123ToDateTime($date);
110-
$result->setAccessTierChangeTime($date);
110+
$accesstierchangetime = Utilities::tryGetValue($clean, 'accesstierchangetime');
111+
if (!is_null($accesstierchangetime)) {
112+
$accesstierchangetime = Utilities::rfc1123ToDateTime($accesstierchangetime);
113+
$result->setAccessTierChangeTime($accesstierchangetime);
111114
}
112115

113116
$result->setArchiveStatus(
114117
Utilities::tryGetValue($clean, 'archivestatus')
115118
);
116119

120+
$deletedtime = Utilities::tryGetValue($clean, 'deletedtime');
121+
if (!is_null($deletedtime)) {
122+
$deletedtime = Utilities::rfc1123ToDateTime($deletedtime);
123+
$result->setDeletedTime($deletedtime);
124+
}
125+
126+
$remainingretentiondays = Utilities::tryGetValue($clean, 'remainingretentiondays');
127+
if (!is_null($remainingretentiondays)) {
128+
$result->setRemainingRetentionDays((int) $remainingretentiondays);
129+
}
130+
131+
$creationtime = Utilities::tryGetValue($clean, 'creation-time');
132+
if (!is_null($creationtime)) {
133+
$creationtime = Utilities::rfc1123ToDateTime($creationtime);
134+
$result->setCreationTime($creationtime);
135+
}
136+
117137
return $result;
118138
}
119139

@@ -217,6 +237,29 @@ public function setLastModified(\DateTime $lastModified)
217237
$this->lastModified = $lastModified;
218238
}
219239

240+
/**
241+
* Gets blob creationTime.
242+
*
243+
* @return \DateTime
244+
*/
245+
public function getCreationTime()
246+
{
247+
return $this->creationTime;
248+
}
249+
250+
/**
251+
* Sets blob creationTime.
252+
*
253+
* @param \DateTime $creationTime value.
254+
*
255+
* @return void
256+
*/
257+
public function setCreationTime(\DateTime $creationTime)
258+
{
259+
Validate::isDate($creationTime);
260+
$this->creationTime = $creationTime;
261+
}
262+
220263
/**
221264
* Gets blob etag.
222265
*
@@ -371,7 +414,52 @@ public function setArchiveStatus($archiveStatus)
371414
{
372415
$this->archiveStatus = $archiveStatus;
373416
}
417+
418+
/**
419+
* Gets blob deleted time.
420+
*
421+
* @return string
422+
*/
423+
public function getDeletedTime()
424+
{
425+
return $this->deletedTime;
426+
}
427+
428+
/**
429+
* Sets blob deleted time.
430+
*
431+
* @param \DateTime $deletedTime value.
432+
*
433+
* @return void
434+
*/
435+
public function setDeletedTime(\DateTime $deletedTime)
436+
{
437+
$this->deletedTime = $deletedTime;
438+
}
439+
440+
/**
441+
* Gets blob remaining retention days.
442+
*
443+
* @return integer
444+
*/
445+
public function getRemainingRetentionDays()
446+
{
447+
return $this->remainingRetentionDays;
448+
}
449+
450+
/**
451+
* Sets blob remaining retention days.
452+
*
453+
* @param integer $remainingRetentionDays value.
454+
*
455+
* @return void
456+
*/
457+
public function setRemainingRetentionDays($remainingRetentionDays)
458+
{
459+
$this->remainingRetentionDays = $remainingRetentionDays;
460+
}
374461

462+
375463
/**
376464
* Gets blob access inferred.
377465
*

src/Blob/Models/ListBlobsOptions.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ListBlobsOptions extends BlobServiceOptions
4848
private $_includeSnapshots;
4949
private $_includeUncommittedBlobs;
5050
private $_includeCopy;
51+
private $_includeDeleted;
5152

5253
/**
5354
* Gets prefix.
@@ -209,4 +210,27 @@ public function setIncludeCopy($includeCopy)
209210
Validate::isBoolean($includeCopy);
210211
$this->_includeCopy = $includeCopy;
211212
}
213+
214+
/**
215+
* Indicates if deleted is included or not.
216+
*
217+
* @return boolean
218+
*/
219+
public function getIncludeDeleted()
220+
{
221+
return $this->_includeDeleted;
222+
}
223+
224+
/**
225+
* Sets the include deleted flag.
226+
*
227+
* @param bool $includeDeleted value.
228+
*
229+
* @return void
230+
*/
231+
public function setIncludeDeleted($includeDeleted)
232+
{
233+
Validate::isBoolean($includeDeleted);
234+
$this->_includeDeleted = $includeDeleted;
235+
}
212236
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/**
4+
* LICENSE: The MIT License (the "License")
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* https://github.com/azure/azure-storage-php/LICENSE
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
* PHP version 5
16+
*
17+
* @category Microsoft
18+
* @package MicrosoftAzure\Storage\Blob\Models
19+
* @author Azure Storage PHP SDK <[email protected]>
20+
* @copyright 2016 Microsoft Corporation
21+
* @license https://github.com/azure/azure-storage-php/LICENSE
22+
* @link https://github.com/azure/azure-storage-php
23+
*/
24+
25+
namespace MicrosoftAzure\Storage\Blob\Models;
26+
27+
/**
28+
* Optional parameters for deleteBlob wrapper
29+
*
30+
* @category Microsoft
31+
* @package MicrosoftAzure\Storage\Blob\Models
32+
* @author Azure Storage PHP SDK <[email protected]>
33+
* @copyright 2016 Microsoft Corporation
34+
* @license https://github.com/azure/azure-storage-php/LICENSE
35+
* @link https://github.com/azure/azure-storage-php
36+
*/
37+
class UndeleteBlobOptions extends BlobServiceOptions
38+
{
39+
}

0 commit comments

Comments
 (0)