Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit c6fd3d9

Browse files
authored
Merge pull request #150 from XiaoningLiu/blobtier
Blob Tier
2 parents 1afdf1c + ec0df7a commit c6fd3d9

29 files changed

Lines changed: 888 additions & 53 deletions

ISSUE_TEMPLATE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Which service(blob, file, queue, table) does this issue concern?
2+
3+
4+
### Which version of the SDK was used?
5+
6+
7+
### What's the PHP/OS version?
8+
9+
10+
### What problem was encountered?
11+
12+
13+
### Steps to reproduce the issue?
14+
15+
16+
### Have you found a mitigation/solution?

azure-storage-blob/ChangeLog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2018.08 - version 1.2.0
2+
3+
* Updated Azure Storage API version from 2016-05-31 to 2017-04-17.
4+
* Added method `setBlobTier` method in `BlobRestProxy` to set blob tiers.
5+
* Added support setting or getting blob tiers related properties when creating blobs, listing blobs, getting blob properties and copying blobs.
6+
* Set the `getBlobUrl()` method in `BlobRestProxy` visibility to public.
7+
18
2018.04 - version 1.1.0
29

310
* Private method BlobRestProxy::getBlobUrl now preserves primary URI path when exists.
@@ -12,7 +19,7 @@
1219

1320
* Created `BlobSharedAccessSignatureHelper` and moved method `SharedAccessSignatureHelper::generateBlobServiceSharedAccessSignatureToken()` into `BlobSharedAccessSignatureHelper`.
1421
* Added static builder methods `createBlobService` and `createContainerAnonymousAccess` into `BlobRestProxy`.
15-
* Removed `dataSerializer` parameter from `BlobRextProxy` constructor.
22+
* Removed `dataSerializer` parameter from `BlobRestProxy` constructor.
1623
* Added `setUseTransactionalMD5` method for options of `BlobRestProxy::CreateBlockBlob` and `BlobRestProxy::CreatePageBlobFromContent`. Default false, enabling transactional MD5 validation will take more cpu and memory resources.
1724
* Fixed a bug that CopyBlobFromURLOptions not found.
1825
* Deprecated PHP 5.5 support.

azure-storage-blob/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.1.0",
3+
"version": "1.2.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.1"
15+
"microsoft/azure-storage-common": "~1.2.0"
1616
},
1717
"autoload": {
1818
"psr-4": {

azure-storage-blob/src/Blob/BlobRestProxy.php

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use MicrosoftAzure\Storage\Blob\Models\CreateBlobSnapshotOptions;
4646
use MicrosoftAzure\Storage\Blob\Models\CreateBlobSnapshotResult;
4747
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
48+
use MicrosoftAzure\Storage\Blob\Models\CreatePageBlobOptions;
4849
use MicrosoftAzure\Storage\Blob\Models\DeleteBlobOptions;
4950
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataOptions;
5051
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataResult;
@@ -71,6 +72,7 @@
7172
use MicrosoftAzure\Storage\Blob\Models\SetBlobMetadataResult;
7273
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesOptions;
7374
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult;
75+
use MicrosoftAzure\Storage\Blob\Models\SetBlobTierOptions;
7476
use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedAccessSignatureAuthScheme;
7577
use MicrosoftAzure\Storage\Common\Internal\Authentication\SharedKeyAuthScheme;
7678
use MicrosoftAzure\Storage\Common\Internal\Http\HttpFormatter;
@@ -376,7 +378,7 @@ private function createPath($container, $blob = '')
376378
*
377379
* @return string
378380
*/
379-
private function getBlobUrl($container, $blob)
381+
public function getBlobUrl($container, $blob)
380382
{
381383
$encodedBlob = $this->createPath($container, $blob);
382384
$uri = $this->getPsrPrimaryUri();
@@ -1337,6 +1339,82 @@ public function setContainerMetadataAsync(
13371339
);
13381340
}
13391341

1342+
/**
1343+
* Sets blob tier on the blob.
1344+
*
1345+
* @param string $container name
1346+
* @param string $blob name of the blob
1347+
* @param Models\SetBlobTierOptions $options optional parameters
1348+
*
1349+
* @return void
1350+
*
1351+
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier
1352+
*/
1353+
public function setBlobTier(
1354+
$container,
1355+
$blob,
1356+
Models\SetBlobTierOptions $options = null
1357+
) {
1358+
$this->setBlobTierAsync($container, $blob, $options)->wait();
1359+
}
1360+
1361+
/**
1362+
* Sets blob tier on the blob.
1363+
*
1364+
* @param string $container name
1365+
* @param string $blob name of the blob
1366+
* @param Models\SetBlobTierOptions $options optional parameters
1367+
*
1368+
* @return \GuzzleHttp\Promise\PromiseInterface
1369+
*
1370+
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier
1371+
*/
1372+
public function setBlobTierAsync(
1373+
$container,
1374+
$blob,
1375+
Models\SetBlobTierOptions $options = null
1376+
)
1377+
{
1378+
Validate::canCastAsString($container, 'container');
1379+
Validate::canCastAsString($blob, 'blob');
1380+
Validate::notNullOrEmpty($blob, 'blob');
1381+
1382+
$method = Resources::HTTP_PUT;
1383+
$headers = array();
1384+
$postParams = array();
1385+
$queryParams = array();
1386+
$path = $this->createPath($container, $blob);
1387+
1388+
if (is_null($options)) {
1389+
$options = new SetBlobTierOptions();
1390+
}
1391+
1392+
$this->addOptionalQueryParam(
1393+
$queryParams,
1394+
Resources::QP_COMP,
1395+
'tier'
1396+
);
1397+
1398+
$this->addOptionalHeader(
1399+
$headers,
1400+
Resources::X_MS_ACCESS_TIER,
1401+
$options->getAccessTier()
1402+
);
1403+
1404+
$options->setLocationMode(LocationMode::PRIMARY_ONLY);
1405+
1406+
return $this->sendAsync(
1407+
$method,
1408+
$headers,
1409+
$queryParams,
1410+
$postParams,
1411+
$path,
1412+
array(Resources::STATUS_OK, Resources::STATUS_ACCEPTED),
1413+
Resources::EMPTY_STRING,
1414+
$options
1415+
);
1416+
}
1417+
13401418
/**
13411419
* Lists all of the blobs in the given container.
13421420
*
@@ -1462,7 +1540,7 @@ public function listBlobsAsync(
14621540
* The page blob size must be
14631541
* aligned to a 512-byte
14641542
* boundary.
1465-
* @param Models\CreateBlobOptions $options The optional parameters.
1543+
* @param Models\CreatePageBlobOptions $options The optional parameters.
14661544
*
14671545
* @return Models\PutBlobResult
14681546
*
@@ -1472,7 +1550,7 @@ public function createPageBlob(
14721550
$container,
14731551
$blob,
14741552
$length,
1475-
Models\CreateBlobOptions $options = null
1553+
Models\CreatePageBlobOptions $options = null
14761554
) {
14771555
return $this->createPageBlobAsync(
14781556
$container,
@@ -1494,7 +1572,7 @@ public function createPageBlob(
14941572
* The page blob size must be
14951573
* aligned to a 512-byte
14961574
* boundary.
1497-
* @param Models\CreateBlobOptions $options The optional parameters.
1575+
* @param Models\CreatePageBlobOptions $options The optional parameters.
14981576
*
14991577
* @return \GuzzleHttp\Promise\PromiseInterface
15001578
*
@@ -1504,7 +1582,7 @@ public function createPageBlobAsync(
15041582
$container,
15051583
$blob,
15061584
$length,
1507-
Models\CreateBlobOptions $options = null
1585+
Models\CreatePageBlobOptions $options = null
15081586
) {
15091587
Validate::canCastAsString($container, 'container');
15101588
Validate::canCastAsString($blob, 'blob');
@@ -1519,7 +1597,7 @@ public function createPageBlobAsync(
15191597
$path = $this->createPath($container, $blob);
15201598

15211599
if (is_null($options)) {
1522-
$options = new CreateBlobOptions();
1600+
$options = new CreatePageBlobOptions();
15231601
}
15241602

15251603
$this->addOptionalHeader(
@@ -1537,6 +1615,11 @@ public function createPageBlobAsync(
15371615
Resources::X_MS_BLOB_SEQUENCE_NUMBER,
15381616
$options->getSequenceNumber()
15391617
);
1618+
$this->addOptionalHeader(
1619+
$headers,
1620+
Resources::X_MS_ACCESS_TIER,
1621+
$options->getAccessTier()
1622+
);
15401623
$headers = $this->addCreateBlobOptionalHeaders($options, $headers);
15411624

15421625
$options->setLocationMode(LocationMode::PRIMARY_ONLY);
@@ -3521,7 +3604,7 @@ public function saveBlobToFile(
35213604
* @param Models\GetBlobOptions $options optional parameters
35223605
*
35233606
* @return \GuzzleHttp\Promise\PromiseInterface
3524-
*
3607+
* @throws \Exception
35253608
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179440.aspx
35263609
*/
35273610
public function saveBlobToFileAsync(
@@ -4024,6 +4107,12 @@ public function copyBlobFromURLAsync(
40244107
$options->getSourceLeaseId()
40254108
);
40264109

4110+
$this->addOptionalHeader(
4111+
$headers,
4112+
Resources::X_MS_ACCESS_TIER,
4113+
$options->getAccessTier()
4114+
);
4115+
40274116
$options->setLocationMode(LocationMode::PRIMARY_ONLY);
40284117

40294118
return $this->sendAsync(

azure-storage-blob/src/Blob/Internal/BlobResources.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class BlobResources extends Resources
4141
{
4242
// @codingStandardsIgnoreStart
4343

44-
const BLOB_SDK_VERSION = '1.1.0';
45-
const STORAGE_API_LATEST_VERSION = '2016-05-31';
44+
const BLOB_SDK_VERSION = '1.2.0';
45+
const STORAGE_API_LATEST_VERSION = '2017-04-17';
4646

4747
// Error messages
4848
const INVALID_BTE_MSG = "The blob block type must exist in %s";
@@ -83,6 +83,10 @@ class BlobResources extends Resources
8383
const X_MS_SERVER_ENCRYPTED = 'x-ms-server-encrypted';
8484
const X_MS_INCREMENTAL_COPY = 'x-ms-incremental-copy';
8585
const X_MS_COPY_DESTINATION_SNAPSHOT = 'x-ms-copy-destination-snapshot';
86+
const X_MS_ACCESS_TIER = 'x-ms-access-tier';
87+
const X_MS_ACCESS_TIER_INFERRED = 'x-ms-access-tier-inferred';
88+
const X_MS_ACCESS_TIER_CHANGE_TIME = 'x-ms-access-tier-change-time';
89+
const X_MS_ARCHIVE_STATUS = 'x-ms-archive-status';
8690
const MAX_BLOB_SIZE = 'x-ms-blob-condition-maxsize';
8791
const MAX_APPEND_POSITION = 'x-ms-blob-condition-appendpos';
8892
const SEQUENCE_NUMBER_LESS_THAN_OR_EQUAL = 'x-ms-if-sequence-number-le';

0 commit comments

Comments
 (0)