├── BreakingChanges.md ├── CONTRIBUTING.md ├── ChangeLog.md ├── LICENSE ├── README.md ├── SECURITY.md ├── composer.json └── src └── Blob ├── BlobRestProxy.php ├── BlobSharedAccessSignatureHelper.php ├── Internal ├── BlobResources.php └── IBlob.php └── Models ├── AccessCondition.php ├── AccessTierTrait.php ├── AppendBlockOptions.php ├── AppendBlockResult.php ├── Blob.php ├── BlobAccessPolicy.php ├── BlobBlockType.php ├── BlobPrefix.php ├── BlobProperties.php ├── BlobServiceOptions.php ├── BlobType.php ├── Block.php ├── BlockList.php ├── BreakLeaseResult.php ├── CommitBlobBlocksOptions.php ├── Container.php ├── ContainerACL.php ├── ContainerAccessPolicy.php ├── ContainerProperties.php ├── CopyBlobFromURLOptions.php ├── CopyBlobOptions.php ├── CopyBlobResult.php ├── CopyState.php ├── CreateBlobBlockOptions.php ├── CreateBlobOptions.php ├── CreateBlobPagesOptions.php ├── CreateBlobPagesResult.php ├── CreateBlobSnapshotOptions.php ├── CreateBlobSnapshotResult.php ├── CreateBlockBlobOptions.php ├── CreateContainerOptions.php ├── CreatePageBlobFromContentOptions.php ├── CreatePageBlobOptions.php ├── DeleteBlobOptions.php ├── GetBlobMetadataOptions.php ├── GetBlobMetadataResult.php ├── GetBlobOptions.php ├── GetBlobPropertiesOptions.php ├── GetBlobPropertiesResult.php ├── GetBlobResult.php ├── GetContainerACLResult.php ├── GetContainerPropertiesResult.php ├── LeaseMode.php ├── LeaseResult.php ├── ListBlobBlocksOptions.php ├── ListBlobBlocksResult.php ├── ListBlobsOptions.php ├── ListBlobsResult.php ├── ListContainersOptions.php ├── ListContainersResult.php ├── ListPageBlobRangesDiffResult.php ├── ListPageBlobRangesOptions.php ├── ListPageBlobRangesResult.php ├── PageWriteOption.php ├── PublicAccessType.php ├── PutBlobResult.php ├── PutBlockResult.php ├── SetBlobMetadataResult.php ├── SetBlobPropertiesOptions.php ├── SetBlobPropertiesResult.php ├── SetBlobTierOptions.php └── UndeleteBlobOptions.php /BreakingChanges.md: -------------------------------------------------------------------------------- 1 | Tracking Breaking changes in 1.0.0 2 | 3 | * Removed `dataSerializer` parameter from `BlobRextProxy` constructor. 4 | * Option parameter type of `BlobRestProxy::CreateBlockBlob` and `BlobRestProxy::CreatePageBlobFromContent` changed and added `setUseTransactionalMD5` method. 5 | * Deprecated PHP 5.5 support. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | This [repository](https://github.com/azure/azure-storage-blob-php) is currently used for releasing only, please go to [azure-storage-php](https://github.com/azure/azure-storage-php) for submitting issues or contribution. -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | 2022.08 - version 1.5.4 2 | * Check `$copyProgress` is not null before using it in `strpos`. 3 | 4 | 2021.09 - version 1.5.3 5 | * Upgraded dependency for `azure-storage-common` to version 1.5.2. 6 | * Resolved some interface inconsistency between `IBlob`/`BlobRestProxy`. 7 | * Imported `Psr\Http\Message\StreamInterface` in `IBlob`. 8 | 9 | 2020.12 - version 1.5.2 10 | * Resolved an issue where access condition does not work for large block blob uploads. 11 | * Guzzle version is now updated to support both 6.x and 7.x. 12 | 13 | 2020.08 - version 1.5.1 14 | * Lower case query parameter names. 15 | 16 | 2020.01 - version 1.5.0 17 | 18 | * Added support to include deleted in blob list. 19 | * Added support to undelete a blob. 20 | * Fixed the issue in SAS token where special characters were not correctly encoded. 21 | * Samples no longer uses ‘BlobRestProxy’ directly, instead, ‘ServicesBuilder’ is used. 22 | 23 | 2019.04 - version 1.4.0 24 | 25 | * Added support for OAuth authentication. 26 | * Resolved some issues on Linux platform. 27 | 28 | 2019.03 - version 1.3.0 29 | 30 | * Fixed a bug where blob name '0' cannot be created. 31 | * Documentation refinement. 32 | * `ListContainer` now can have ETag more robustly fetched from response header. 33 | 34 | 2018.08 - version 1.2.0 35 | 36 | * Updated Azure Storage API version from 2016-05-31 to 2017-04-17. 37 | * Added method `setBlobTier` method in `BlobRestProxy` to set blob tiers. 38 | * Added support setting or getting blob tiers related properties when creating blobs, listing blobs, getting blob properties and copying blobs. 39 | * Set the `getBlobUrl()` method in `BlobRestProxy` visibility to public. 40 | 41 | 2018.04 - version 1.1.0 42 | 43 | * Private method BlobRestProxy::getBlobUrl now preserves primary URI path when exists. 44 | * MD files are modified for better readability and formatting. 45 | * CACERT can now be set when creating RestProxies using `$options` parameter. 46 | * Added a sample in `BlobSamples.php` to list all blobs with certain prefix. This is a recommended implementation of using continuation token to list all the blobs. 47 | * Removed unnecessary trailing spaces. 48 | * Assertions are re-factored in test cases. 49 | * Now the test framework uses `PHPUnit\Framework\TestCase` instead of `PHPUnit_Framework_TestCase`. 50 | 51 | 2018.01 - version 1.0.0 52 | 53 | * Created `BlobSharedAccessSignatureHelper` and moved method `SharedAccessSignatureHelper::generateBlobServiceSharedAccessSignatureToken()` into `BlobSharedAccessSignatureHelper`. 54 | * Added static builder methods `createBlobService` and `createContainerAnonymousAccess` into `BlobRestProxy`. 55 | * Removed `dataSerializer` parameter from `BlobRestProxy` constructor. 56 | * Added `setUseTransactionalMD5` method for options of `BlobRestProxy::CreateBlockBlob` and `BlobRestProxy::CreatePageBlobFromContent`. Default false, enabling transactional MD5 validation will take more cpu and memory resources. 57 | * Fixed a bug that CopyBlobFromURLOptions not found. 58 | * Deprecated PHP 5.5 support. 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft Azure Storage Blob PHP Client Library (Deprecated) 2 | 3 | For more details on the retirement and alternatives to using this project, visit [Retirement notice: The Azure Storage PHP client libraries will be retired on 17 March 2024](https://aka.ms/AzStoragePHPSDKRetirement). 4 | 5 | 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/). 6 | 7 | [![Latest Stable Version](https://poser.pugx.org/microsoft/azure-storage-blob/v/stable)](https://packagist.org/packages/microsoft/azure-storage-blob) 8 | 9 | > **Note** 10 | > 11 | > * This [repository](https://github.com/azure/azure-storage-blob-php) is currently used for releasing only, please go to [azure-storage-php](https://github.com/azure/azure-storage-php) for submitting issues or contribution. 12 | > * If you are looking for the Service Bus, Service Runtime, Service Management or Media Services libraries, please visit https://github.com/Azure/azure-sdk-for-php. 13 | > * If you need big file (larger than 2GB) or 64-bit integer support, please install PHP 7 64-bit version. 14 | 15 | # Features 16 | 17 | * Blobs 18 | * create, list, and delete containers, work with container metadata and permissions, list blobs in container 19 | * create block and page blobs (from a stream or a string), work with blob blocks and pages, delete blobs 20 | * work with blob properties, metadata, leases, snapshot a blob 21 | 22 | Please check details on [API reference documents](https://azure.github.io/azure-storage-php). 23 | 24 | # Getting Started 25 | ## Minimum Requirements 26 | 27 | * PHP 5.6 or above 28 | * See [composer.json](composer.json) for dependencies 29 | * Required extension for PHP: 30 | * php_fileinfo.dll 31 | * php_mbstring.dll 32 | * php_openssl.dll 33 | * php_xsl.dll 34 | 35 | * Recommended extension for PHP: 36 | * php_curl.dll 37 | 38 | ## Download Source Code 39 | 40 | To get the source code from GitHub, type 41 | 42 | ``` 43 | git clone https://github.com/Azure/azure-storage-php.git 44 | cd ./azure-storage-php 45 | ``` 46 | 47 | ## Install via Composer 48 | 49 | 1. Create a file named **composer.json** in the root of your project and add the following code to it: 50 | ```json 51 | { 52 | "require": { 53 | "microsoft/azure-storage-blob": "*" 54 | } 55 | } 56 | ``` 57 | 2. Download **[composer.phar](https://getcomposer.org/composer.phar)** in your project root. 58 | 59 | 3. Open a command prompt and execute this in your project root 60 | 61 | ``` 62 | php composer.phar install 63 | ``` 64 | 65 | ## Usage 66 | 67 | There are four basic steps that have to be performed before you can make a call to any Microsoft Azure Storage API when using the libraries. 68 | 69 | * First, include the autoloader script: 70 | 71 | ```php 72 | require_once "vendor/autoload.php"; 73 | ``` 74 | 75 | * Include the namespaces you are going to use. 76 | 77 | To create any Microsoft Azure service client you need to use the rest proxy classes, such as **BlobRestProxy** class: 78 | 79 | ```php 80 | use MicrosoftAzure\Storage\Blob\BlobRestProxy; 81 | ``` 82 | 83 | To process exceptions you need: 84 | 85 | ```php 86 | use MicrosoftAzure\Storage\Common\ServiceException; 87 | ``` 88 | 89 | * To instantiate the service client you will also need a valid [connection string](https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/). The format is: 90 | 91 | ``` 92 | DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey] 93 | ``` 94 | 95 | or: 96 | 97 | ``` 98 | BlobEndpoint=[myBlobEndpoint];SharedAccessSignature=[sasToken] 99 | ``` 100 | 101 | * Instantiate a client object - a wrapper around the available calls for the given service. 102 | 103 | ```php 104 | $blobClient = BlobRestProxy::createBlobService($connectionString); 105 | ``` 106 | Or for token authentication: 107 | ```php 108 | $blobClient = BlobRestProxy::createBlobServiceWithTokenCredential($token, $connectionString); 109 | ``` 110 | ### Using Middlewares 111 | To specify the middlewares, user have to create an array with middlewares 112 | and put it in the `$requestOptions` with key 'middlewares'. The sequence of 113 | the array will affect the sequence in which the middleware is invoked. The 114 | `$requestOptions` can usually be set in the options of an API call, such as 115 | `MicrosoftAzure\Storage\Blob\Models\ListBlobOptions`. 116 | 117 | The user can push the middleware into the array with key 'middlewares' in 118 | services' `$_options` instead when creating them if the middleware is to be 119 | applied to each of the API call for a rest proxy. These middlewares will always 120 | be invoked after the middlewares in the `$requestOptions`. 121 | e.g.: 122 | ```php 123 | $blobClient = BlobRestProxy::createBlobService( 124 | $connectionString, 125 | $optionsWithMiddlewares 126 | ); 127 | ``` 128 | 129 | Each of the middleware should be either an instance of a sub-class that 130 | implements `MicrosoftAzure\Storage\Common\Internal\IMiddleware`, or a 131 | `callable` that follows the Guzzle middleware implementation convention. 132 | 133 | User can create self-defined middleware that inherits from `MicrosoftAzure\Storage\Common\Internal\Middlewares\MiddlewareBase`. 134 | 135 | ### Using proxies 136 | To use proxies during HTTP requests, set system variable `HTTP_PROXY` and the proxy will be used. 137 | 138 | ## Troubleshooting 139 | ### Error: Unable to get local issuer certificate 140 | 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: 141 | 142 | 1. Download the cacert.pem file from [cURL site](https://curl.haxx.se/docs/caextract.html). 143 | 144 | 2. Then either: 145 | * Open your php.ini file and add the following line: 146 | ```ini 147 | curl.cainfo = "" 148 | ``` 149 | OR 150 | * Point to the cacert in the options when creating the Proxy. 151 | ```php 152 | $options["http"] = ["verify" => ""]; 153 | BlobRestProxy::createBlobService($connectionString, $options); 154 | ``` 155 | 156 | ## Code samples 157 | 158 | You can find samples in the [samples folder](https://github.com/Azure/azure-storage-php/tree/master/samples) 159 | 160 | 161 | # Migrate from [Azure SDK for PHP](https://github.com/Azure/azure-sdk-for-php/) 162 | 163 | If you are using [Azure SDK for PHP](https://github.com/Azure/azure-sdk-for-php/) to access Azure Storage Service, we highly recommend you to migrate to this SDK for faster issue resolution and quicker feature implementation. We are working on supporting the latest service features as well as improvement on existing APIs. 164 | 165 | For now, Microsoft Azure Storage PHP client libraries share almost the same interface as the storage blobs, tables, queues and files APIs in Azure SDK for PHP. However, there are some minor breaking changes need to be addressed during your migration. You can find the details in [BreakingChanges.md](BreakingChanges.md). 166 | 167 | # Need Help? 168 | 169 | 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. 170 | 171 | # Contribute Code or Provide Feedback 172 | 173 | If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](https://opensource.microsoft.com/program/#program-contributing). 174 | You can find more details for contributing in the [CONTRIBUTING.md](CONTRIBUTING.md). 175 | 176 | 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. 177 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "microsoft/azure-storage-blob", 3 | "version": "1.5.4", 4 | "description": "This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.", 5 | "keywords": [ "php", "azure", "storage", "sdk", "blob" ], 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Azure Storage PHP Client Library", 10 | "email": "dmsh@microsoft.com" 11 | } 12 | ], 13 | "require": { 14 | "php": ">=5.6.0", 15 | "microsoft/azure-storage-common": "~1.5" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "MicrosoftAzure\\Storage\\Blob\\": "src/Blob" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Blob/Internal/BlobResources.php: -------------------------------------------------------------------------------- 1 | 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\Internal; 26 | 27 | use MicrosoftAzure\Storage\Common\Internal\Resources; 28 | 29 | /** 30 | * Project resources. 31 | * 32 | * @ignore 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Common\Internal 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2017 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class BlobResources extends Resources 41 | { 42 | // @codingStandardsIgnoreStart 43 | 44 | const BLOB_SDK_VERSION = '1.5.4'; 45 | const STORAGE_API_LATEST_VERSION = '2017-11-09'; 46 | 47 | // Error messages 48 | const INVALID_BTE_MSG = "The blob block type must exist in %s"; 49 | const INVALID_BLOB_PAT_MSG = 'The provided access type is invalid.'; 50 | const INVALID_ACH_MSG = 'The provided access condition header is invalid'; 51 | const ERROR_TOO_LARGE_FOR_BLOCK_BLOB = 'Error: Exceeds the upper limit of the blob.'; 52 | const ERROR_RANGE_NOT_ALIGN_TO_512 = 'Error: Range of the page blob must be align to 512'; 53 | const ERROR_CONTAINER_NOT_EXIST = 'The specified container does not exist'; 54 | const ERROR_BLOB_NOT_EXIST = 'The specified blob does not exist'; 55 | const CONTENT_SIZE_TOO_LARGE = 'The content is too large for the selected blob type.'; 56 | 57 | // Headers 58 | const X_MS_BLOB_PUBLIC_ACCESS = 'x-ms-blob-public-access'; 59 | const X_MS_BLOB_SEQUENCE_NUMBER = 'x-ms-blob-sequence-number'; 60 | const X_MS_BLOB_SEQUENCE_NUMBER_ACTION = 'x-ms-sequence-number-action'; 61 | const X_MS_BLOB_TYPE = 'x-ms-blob-type'; 62 | const X_MS_BLOB_CONTENT_TYPE = 'x-ms-blob-content-type'; 63 | const X_MS_BLOB_CONTENT_ENCODING = 'x-ms-blob-content-encoding'; 64 | const X_MS_BLOB_CONTENT_LANGUAGE = 'x-ms-blob-content-language'; 65 | const X_MS_BLOB_CONTENT_MD5 = 'x-ms-blob-content-md5'; 66 | const X_MS_BLOB_CACHE_CONTROL = 'x-ms-blob-cache-control'; 67 | const X_MS_BLOB_CONTENT_DISPOSITION = 'x-ms-blob-content-disposition'; 68 | const X_MS_BLOB_CONTENT_LENGTH = 'x-ms-blob-content-length'; 69 | const X_MS_BLOB_CONDITION_MAXSIZE = 'x-ms-blob-condition-maxsize'; 70 | const X_MS_BLOB_CONDITION_APPENDPOS = 'x-ms-blob-condition-appendpos'; 71 | const X_MS_BLOB_APPEND_OFFSET = 'x-ms-blob-append-offset'; 72 | const X_MS_BLOB_COMMITTED_BLOCK_COUNT = 'x-ms-blob-committed-block-count'; 73 | const X_MS_LEASE_DURATION = 'x-ms-lease-duration'; 74 | const X_MS_LEASE_ID = 'x-ms-lease-id'; 75 | const X_MS_LEASE_TIME = 'x-ms-lease-time'; 76 | const X_MS_LEASE_STATUS = 'x-ms-lease-status'; 77 | const X_MS_LEASE_STATE = 'x-ms-lease-state'; 78 | const X_MS_LEASE_ACTION = 'x-ms-lease-action'; 79 | const X_MS_PROPOSED_LEASE_ID = 'x-ms-proposed-lease-id'; 80 | const X_MS_LEASE_BREAK_PERIOD = 'x-ms-lease-break-period'; 81 | const X_MS_PAGE_WRITE = 'x-ms-page-write'; 82 | const X_MS_REQUEST_SERVER_ENCRYPTED = 'x-ms-request-server-encrypted'; 83 | const X_MS_SERVER_ENCRYPTED = 'x-ms-server-encrypted'; 84 | const X_MS_INCREMENTAL_COPY = 'x-ms-incremental-copy'; 85 | 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'; 90 | const MAX_BLOB_SIZE = 'x-ms-blob-condition-maxsize'; 91 | const MAX_APPEND_POSITION = 'x-ms-blob-condition-appendpos'; 92 | const SEQUENCE_NUMBER_LESS_THAN_OR_EQUAL = 'x-ms-if-sequence-number-le'; 93 | const SEQUENCE_NUMBER_LESS_THAN = 'x-ms-if-sequence-number-lt'; 94 | const SEQUENCE_NUMBER_EQUAL = 'x-ms-if-sequence-number-eq'; 95 | const BLOB_CONTENT_MD5 = 'x-ms-blob-content-md5'; 96 | 97 | // Query parameters 98 | const QP_DELIMITER = 'Delimiter'; 99 | const QP_BLOCKID = 'blockid'; 100 | const QP_BLOCK_LIST_TYPE = 'blocklisttype'; 101 | const QP_PRE_SNAPSHOT = 'prevsnapshot'; 102 | 103 | // Resource permissions 104 | const ACCESS_PERMISSIONS = [ 105 | Resources::RESOURCE_TYPE_BLOB => ['r', 'a', 'c', 'w', 'd'], 106 | Resources::RESOURCE_TYPE_CONTAINER => ['r', 'a', 'c', 'w', 'd', 'l'] 107 | ]; 108 | 109 | // @codingStandardsIgnoreEnd 110 | } 111 | -------------------------------------------------------------------------------- /src/Blob/Models/AccessTierTrait.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2018 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 | * Trait implementing setting and getting accessTier. 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 33 | * @copyright 2018 Microsoft Corporation 34 | * @license https://github.com/azure/azure-storage-php/LICENSE 35 | * @link https://github.com/azure/azure-storage-php 36 | */ 37 | trait AccessTierTrait 38 | { 39 | /** 40 | * @var string $accessTier Version 2017-04-17 and newer. For page blobs on a premium storage account, otherwise a block blob 41 | * on blob storage account or storageV2 general account. 42 | * Specifies the tier to be set on the blob. Currently, for block blob, tiers like "Hot", "Cool" 43 | * and "Archive" can be used; for premium page blobs, "P4", "P6", "P10" and etc. can be set. 44 | * Check following link for a full list of supported tiers. 45 | * https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tier 46 | */ 47 | private $accessTier; 48 | 49 | /** 50 | * Gets blob access tier. 51 | * 52 | * @return string 53 | */ 54 | public function getAccessTier() 55 | { 56 | return $this->accessTier; 57 | } 58 | 59 | /** 60 | * Sets blob access tier. 61 | * 62 | * @param string $accessTier value. 63 | * 64 | * @return void 65 | */ 66 | public function setAccessTier($accessTier) 67 | { 68 | $this->accessTier = $accessTier; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Blob/Models/AppendBlockOptions.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2017 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 appendBlock wrapper 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 AppendBlockOptions extends BlobServiceOptions 38 | { 39 | private $contentMD5; 40 | private $maxBlobSize; 41 | private $appendPosition; 42 | 43 | /** 44 | * Gets block contentMD5. 45 | * 46 | * @return string 47 | */ 48 | public function getContentMD5() 49 | { 50 | return $this->contentMD5; 51 | } 52 | 53 | /** 54 | * Sets block contentMD5. 55 | * 56 | * @param string $contentMD5 value. 57 | * 58 | * @return void 59 | */ 60 | public function setContentMD5($contentMD5) 61 | { 62 | $this->contentMD5 = $contentMD5; 63 | } 64 | 65 | /** 66 | * Gets the max length in bytes allowed for the append blob to grow to. 67 | * 68 | * @return int 69 | */ 70 | public function getMaxBlobSize() 71 | { 72 | return $this->maxBlobSize; 73 | } 74 | 75 | /** 76 | * Sets the max length in bytes allowed for the append blob to grow to. 77 | * 78 | * @param int $maxBlobSize value. 79 | * 80 | * @return void 81 | */ 82 | public function setMaxBlobSize($maxBlobSize) 83 | { 84 | $this->maxBlobSize = $maxBlobSize; 85 | } 86 | 87 | /** 88 | * Gets append blob appendPosition. 89 | * 90 | * @return int 91 | */ 92 | public function getAppendPosition() 93 | { 94 | return $this->appendPosition; 95 | } 96 | 97 | /** 98 | * Sets append blob appendPosition. 99 | * 100 | * @param int $appendPosition value. 101 | * 102 | * @return void 103 | */ 104 | public function setAppendPosition($appendPosition) 105 | { 106 | $this->appendPosition = $appendPosition; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/Blob/Models/AppendBlockResult.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2017 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | 30 | /** 31 | * The result of calling appendBlock API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class AppendBlockResult 41 | { 42 | private $appendOffset; 43 | private $committedBlockCount; 44 | private $contentMD5; 45 | private $etag; 46 | private $lastModified; 47 | private $requestServerEncrypted; 48 | 49 | /** 50 | * Creates AppendBlockResult object from the response of the put block request. 51 | * 52 | * @param array $headers The HTTP response headers in array representation. 53 | * 54 | * @internal 55 | * 56 | * @return AppendBlockResult 57 | */ 58 | public static function create(array $headers) 59 | { 60 | $result = new AppendBlockResult(); 61 | 62 | $result->setAppendOffset( 63 | intval( 64 | Utilities::tryGetValueInsensitive( 65 | Resources::X_MS_BLOB_APPEND_OFFSET, $headers 66 | ) 67 | ) 68 | ); 69 | 70 | $result->setCommittedBlockCount( 71 | intval( 72 | Utilities::tryGetValueInsensitive( 73 | Resources::X_MS_BLOB_COMMITTED_BLOCK_COUNT, $headers 74 | ) 75 | ) 76 | ); 77 | 78 | $result->setContentMD5( 79 | Utilities::tryGetValueInsensitive(Resources::CONTENT_MD5, $headers) 80 | ); 81 | 82 | $result->setEtag( 83 | Utilities::tryGetValueInsensitive(Resources::ETAG, $headers) 84 | ); 85 | 86 | if (Utilities::arrayKeyExistsInsensitive( 87 | Resources::LAST_MODIFIED, 88 | $headers 89 | )) { 90 | $lastModified = Utilities::tryGetValueInsensitive( 91 | Resources::LAST_MODIFIED, 92 | $headers 93 | ); 94 | $lastModified = Utilities::rfc1123ToDateTime($lastModified); 95 | 96 | $result->setLastModified($lastModified); 97 | } 98 | 99 | $result->setRequestServerEncrypted( 100 | Utilities::toBoolean( 101 | Utilities::tryGetValueInsensitive( 102 | Resources::X_MS_REQUEST_SERVER_ENCRYPTED, 103 | $headers 104 | ), 105 | true 106 | ) 107 | ); 108 | 109 | return $result; 110 | } 111 | 112 | /** 113 | * Gets Etag of the blob that the client can use to perform conditional 114 | * PUT operations by using the If-Match request header. 115 | * 116 | * @return string 117 | */ 118 | public function getEtag() 119 | { 120 | return $this->etag; 121 | } 122 | 123 | /** 124 | * Sets the etag value. 125 | * 126 | * @param string $etag etag as a string. 127 | * 128 | * @return void 129 | */ 130 | protected function setEtag($etag) 131 | { 132 | $this->etag = $etag; 133 | } 134 | 135 | /** 136 | * Gets $lastModified value. 137 | * 138 | * @return \DateTime 139 | */ 140 | public function getLastModified() 141 | { 142 | return $this->lastModified; 143 | } 144 | 145 | /** 146 | * Sets the $lastModified value. 147 | * 148 | * @param \DateTime $lastModified $lastModified value. 149 | * 150 | * @return void 151 | */ 152 | protected function setLastModified($lastModified) 153 | { 154 | $this->lastModified = $lastModified; 155 | } 156 | 157 | /** 158 | * Gets block content MD5. 159 | * 160 | * @return string 161 | */ 162 | public function getContentMD5() 163 | { 164 | return $this->contentMD5; 165 | } 166 | 167 | /** 168 | * Sets the content MD5 value. 169 | * 170 | * @param string $contentMD5 conent MD5 as a string. 171 | * 172 | * @return void 173 | */ 174 | protected function setContentMD5($contentMD5) 175 | { 176 | $this->contentMD5 = $contentMD5; 177 | } 178 | 179 | /** 180 | * Gets the offset at which the block was committed, in bytes. 181 | * 182 | * @return int 183 | */ 184 | public function getAppendOffset() 185 | { 186 | return $this->appendOffset; 187 | } 188 | 189 | /** 190 | * Sets the offset at which the block was committed, in bytes. 191 | * 192 | * @param int $appendOffset append offset, in bytes. 193 | * 194 | * @return void 195 | */ 196 | protected function setAppendOffset($appendOffset) 197 | { 198 | $this->appendOffset = $appendOffset; 199 | } 200 | 201 | /** 202 | * Gets the number of committed blocks present in the blob. 203 | * 204 | * @return int 205 | */ 206 | public function getCommittedBlockCount() 207 | { 208 | return $this->committedBlockCount; 209 | } 210 | 211 | /** 212 | * Sets the number of committed blocks present in the blob. 213 | * 214 | * @param int $committedBlockCount the number of committed blocks present in the blob. 215 | * 216 | * @return void 217 | */ 218 | protected function setCommittedBlockCount($committedBlockCount) 219 | { 220 | $this->committedBlockCount = $committedBlockCount; 221 | } 222 | 223 | /** 224 | * Gets the whether the contents of the request are successfully encrypted. 225 | * 226 | * @return boolean 227 | */ 228 | public function getRequestServerEncrypted() 229 | { 230 | return $this->requestServerEncrypted; 231 | } 232 | 233 | /** 234 | * Sets the request server encryption value. 235 | * 236 | * @param boolean $requestServerEncrypted 237 | * 238 | * @return void 239 | */ 240 | public function setRequestServerEncrypted($requestServerEncrypted) 241 | { 242 | $this->requestServerEncrypted = $requestServerEncrypted; 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /src/Blob/Models/Blob.php: -------------------------------------------------------------------------------- 1 | 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 | * Represents windows azure blob object 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 Blob 38 | { 39 | private $_name; 40 | private $_url; 41 | private $_snapshot; 42 | private $_metadata; 43 | private $_properties; 44 | /** 45 | * Gets blob name. 46 | * 47 | * @return string 48 | */ 49 | public function getName() 50 | { 51 | return $this->_name; 52 | } 53 | 54 | /** 55 | * Sets blob name. 56 | * 57 | * @param string $name value. 58 | * 59 | * @return void 60 | */ 61 | public function setName($name) 62 | { 63 | $this->_name = $name; 64 | } 65 | 66 | /** 67 | * Gets blob snapshot. 68 | * 69 | * @return string 70 | */ 71 | public function getSnapshot() 72 | { 73 | return $this->_snapshot; 74 | } 75 | 76 | /** 77 | * Sets blob snapshot. 78 | * 79 | * @param string $snapshot value. 80 | * 81 | * @return void 82 | */ 83 | public function setSnapshot($snapshot) 84 | { 85 | $this->_snapshot = $snapshot; 86 | } 87 | 88 | /** 89 | * Gets blob url. 90 | * 91 | * @return string 92 | */ 93 | public function getUrl() 94 | { 95 | return $this->_url; 96 | } 97 | 98 | /** 99 | * Sets blob url. 100 | * 101 | * @param string $url value. 102 | * 103 | * @return void 104 | */ 105 | public function setUrl($url) 106 | { 107 | $this->_url = $url; 108 | } 109 | 110 | /** 111 | * Gets blob metadata. 112 | * 113 | * @return array 114 | */ 115 | public function getMetadata() 116 | { 117 | return $this->_metadata; 118 | } 119 | 120 | /** 121 | * Sets blob metadata. 122 | * 123 | * @param array $metadata value. 124 | * 125 | * @return void 126 | */ 127 | public function setMetadata(array $metadata = null) 128 | { 129 | $this->_metadata = $metadata; 130 | } 131 | 132 | /** 133 | * Gets blob properties. 134 | * 135 | * @return BlobProperties 136 | */ 137 | public function getProperties() 138 | { 139 | return $this->_properties; 140 | } 141 | 142 | /** 143 | * Sets blob properties. 144 | * 145 | * @param BlobProperties $properties value. 146 | * 147 | * @return void 148 | */ 149 | public function setProperties($properties) 150 | { 151 | $this->_properties = $properties; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/Blob/Models/BlobAccessPolicy.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2017 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources; 28 | use MicrosoftAzure\Storage\Common\Models\AccessPolicy; 29 | 30 | /** 31 | * Holds access policy elements 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2017 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class BlobAccessPolicy extends AccessPolicy 41 | { 42 | /** 43 | * Get the valid permissions for the given resource. 44 | * 45 | * @return array 46 | */ 47 | public static function getResourceValidPermissions() 48 | { 49 | return BlobResources::ACCESS_PERMISSIONS[ 50 | BlobResources::RESOURCE_TYPE_BLOB 51 | ]; 52 | } 53 | 54 | /** 55 | * Constructor 56 | */ 57 | public function __construct() 58 | { 59 | parent::__construct(BlobResources::RESOURCE_TYPE_BLOB); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Blob/Models/BlobBlockType.php: -------------------------------------------------------------------------------- 1 | 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 | * Holds available blob block types 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 BlobBlockType 38 | { 39 | const COMMITTED_TYPE = 'Committed'; 40 | const UNCOMMITTED_TYPE = 'Uncommitted'; 41 | const LATEST_TYPE = 'Latest'; 42 | 43 | /** 44 | * Validates the provided type. 45 | * 46 | * @param string $type The entry type. 47 | * 48 | * @internal 49 | * 50 | * @return boolean 51 | */ 52 | public static function isValid($type) 53 | { 54 | switch ($type) { 55 | case self::COMMITTED_TYPE: 56 | case self::LATEST_TYPE: 57 | case self::UNCOMMITTED_TYPE: 58 | return true; 59 | 60 | default: 61 | return false; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Blob/Models/BlobPrefix.php: -------------------------------------------------------------------------------- 1 | 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 | * Represents BlobPrefix object 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 BlobPrefix 38 | { 39 | private $_name; 40 | 41 | /** 42 | * Gets blob name. 43 | * 44 | * @return string 45 | */ 46 | public function getName() 47 | { 48 | return $this->_name; 49 | } 50 | 51 | /** 52 | * Sets blob name. 53 | * 54 | * @param string $name value. 55 | * 56 | * @return void 57 | */ 58 | public function setName($name) 59 | { 60 | $this->_name = $name; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Blob/Models/BlobServiceOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Models\ServiceOptions; 28 | 29 | /** 30 | * Blob service options. 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class BlobServiceOptions extends ServiceOptions 40 | { 41 | private $_leaseId; 42 | private $_accessConditions; 43 | 44 | /** 45 | * Gets lease Id for the blob 46 | * 47 | * @return string 48 | */ 49 | public function getLeaseId() 50 | { 51 | return $this->_leaseId; 52 | } 53 | 54 | /** 55 | * Sets lease Id for the blob 56 | * 57 | * @param string $leaseId the blob lease id. 58 | * 59 | * @return void 60 | */ 61 | public function setLeaseId($leaseId) 62 | { 63 | $this->_leaseId = $leaseId; 64 | } 65 | 66 | /** 67 | * Gets access condition 68 | * 69 | * @return \MicrosoftAzure\Storage\Blob\Models\AccessCondition[] 70 | */ 71 | public function getAccessConditions() 72 | { 73 | return $this->_accessConditions; 74 | } 75 | 76 | /** 77 | * Sets access condition 78 | * 79 | * @param mixed $accessConditions value to use. 80 | * 81 | * @return void 82 | */ 83 | public function setAccessConditions($accessConditions) 84 | { 85 | if (!is_null($accessConditions) && 86 | is_array($accessConditions)) { 87 | $this->_accessConditions = $accessConditions; 88 | } else { 89 | $this->_accessConditions = [$accessConditions]; 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Blob/Models/BlobType.php: -------------------------------------------------------------------------------- 1 | 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 | * Encapsulates blob types 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 BlobType 38 | { 39 | const BLOCK_BLOB = 'BlockBlob'; 40 | const PAGE_BLOB = 'PageBlob'; 41 | const APPEND_BLOB = 'AppendBlob'; 42 | } 43 | -------------------------------------------------------------------------------- /src/Blob/Models/Block.php: -------------------------------------------------------------------------------- 1 | 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 | * Holds information about blob block. 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 Block 38 | { 39 | private $_blockId; 40 | private $_type; 41 | 42 | /** 43 | * Constructor. 44 | * 45 | * @param string $blockId The ID of this block. 46 | * @param string $type The type of the block. 47 | */ 48 | public function __construct($blockId = '', $type = '') 49 | { 50 | $this->_blockId = $blockId; 51 | $this->_type = $type; 52 | } 53 | 54 | /** 55 | * Sets the blockId. 56 | * 57 | * @param string $blockId The id of the block. 58 | * 59 | * @return void 60 | */ 61 | public function setBlockId($blockId) 62 | { 63 | $this->_blockId = $blockId; 64 | } 65 | 66 | /** 67 | * Gets the blockId. 68 | * 69 | * @return string 70 | */ 71 | public function getBlockId() 72 | { 73 | return $this->_blockId; 74 | } 75 | 76 | /** 77 | * Sets the type. 78 | * 79 | * @param string $type The type of the block. 80 | * 81 | * @return void 82 | */ 83 | public function setType($type) 84 | { 85 | $this->_type = $type; 86 | } 87 | 88 | /** 89 | * Gets the type. 90 | * 91 | * @return string 92 | */ 93 | public function getType() 94 | { 95 | return $this->_type; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/Blob/Models/BlockList.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Validate; 29 | use MicrosoftAzure\Storage\Common\Internal\Serialization\XmlSerializer; 30 | 31 | /** 32 | * Holds block list used for commitBlobBlocks 33 | * 34 | * @category Microsoft 35 | * @package MicrosoftAzure\Storage\Blob\Models 36 | * @author Azure Storage PHP SDK 37 | * @copyright 2016 Microsoft Corporation 38 | * @license https://github.com/azure/azure-storage-php/LICENSE 39 | * @link https://github.com/azure/azure-storage-php 40 | */ 41 | class BlockList 42 | { 43 | private $entries; 44 | private static $xmlRootName = 'BlockList'; 45 | 46 | /** 47 | * Creates block list from array of blocks. 48 | * 49 | * @param Block[] The blocks array. 50 | * 51 | * @return BlockList 52 | */ 53 | public static function create(array $array) 54 | { 55 | $blockList = new BlockList(); 56 | 57 | foreach ($array as $value) { 58 | $blockList->addEntry($value->getBlockId(), $value->getType()); 59 | } 60 | 61 | return $blockList; 62 | } 63 | 64 | /** 65 | * Adds new entry to the block list entries. 66 | * 67 | * @param string $blockId The block id. 68 | * @param string $type The entry type, you can use BlobBlockType. 69 | * 70 | * @return void 71 | */ 72 | public function addEntry($blockId, $type) 73 | { 74 | Validate::canCastAsString($blockId, 'blockId'); 75 | Validate::isTrue( 76 | BlobBlockType::isValid($type), 77 | sprintf(Resources::INVALID_BTE_MSG, get_class(new BlobBlockType())) 78 | ); 79 | $block = new Block(); 80 | $block->setBlockId($blockId); 81 | $block->setType($type); 82 | 83 | $this->entries[] = $block; 84 | } 85 | 86 | /** 87 | * Addds committed block entry. 88 | * 89 | * @param string $blockId The block id. 90 | * 91 | * @return void 92 | */ 93 | public function addCommittedEntry($blockId) 94 | { 95 | $this->addEntry($blockId, BlobBlockType::COMMITTED_TYPE); 96 | } 97 | 98 | /** 99 | * Addds uncommitted block entry. 100 | * 101 | * @param string $blockId The block id. 102 | * 103 | * @return void 104 | */ 105 | public function addUncommittedEntry($blockId) 106 | { 107 | $this->addEntry($blockId, BlobBlockType::UNCOMMITTED_TYPE); 108 | } 109 | 110 | /** 111 | * Addds latest block entry. 112 | * 113 | * @param string $blockId The block id. 114 | * 115 | * @return void 116 | */ 117 | public function addLatestEntry($blockId) 118 | { 119 | $this->addEntry($blockId, BlobBlockType::LATEST_TYPE); 120 | } 121 | 122 | /** 123 | * Gets blob block entry. 124 | * 125 | * @param string $blockId The id of the block. 126 | * 127 | * @return Block 128 | */ 129 | public function getEntry($blockId) 130 | { 131 | foreach ($this->entries as $value) { 132 | if ($blockId == $value->getBlockId()) { 133 | return $value; 134 | } 135 | } 136 | 137 | return null; 138 | } 139 | 140 | /** 141 | * Gets all blob block entries. 142 | * 143 | * @return Block[] 144 | */ 145 | public function getEntries() 146 | { 147 | return $this->entries; 148 | } 149 | 150 | /** 151 | * Converts the BlockList object to XML representation 152 | * 153 | * @param XmlSerializer $xmlSerializer The XML serializer. 154 | * 155 | * @internal 156 | * 157 | * @return string 158 | */ 159 | public function toXml(XmlSerializer $xmlSerializer) 160 | { 161 | $properties = array(XmlSerializer::ROOT_NAME => self::$xmlRootName); 162 | $array = array(); 163 | 164 | foreach ($this->entries as $value) { 165 | $array[] = array( 166 | $value->getType() => $value->getBlockId() 167 | ); 168 | } 169 | 170 | return $xmlSerializer->serialize($array, $properties); 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/Blob/Models/BreakLeaseResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | 30 | /** 31 | * The result of calling breakLease API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class BreakLeaseResult 41 | { 42 | private $_leaseTime; 43 | 44 | /** 45 | * Creates BreakLeaseResult from response headers 46 | * 47 | * @param array $headers response headers 48 | * 49 | * @return BreakLeaseResult 50 | */ 51 | public static function create($headers) 52 | { 53 | $result = new BreakLeaseResult(); 54 | 55 | $result->setLeaseTime( 56 | Utilities::tryGetValue($headers, Resources::X_MS_LEASE_TIME) 57 | ); 58 | 59 | return $result; 60 | } 61 | 62 | /** 63 | * Gets lease time. 64 | * 65 | * @return string 66 | */ 67 | public function getLeaseTime() 68 | { 69 | return $this->_leaseTime; 70 | } 71 | 72 | /** 73 | * Sets lease time. 74 | * 75 | * @param string $leaseTime the blob lease time. 76 | * 77 | * @return void 78 | */ 79 | protected function setLeaseTime($leaseTime) 80 | { 81 | $this->_leaseTime = $leaseTime; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/Blob/Models/CommitBlobBlocksOptions.php: -------------------------------------------------------------------------------- 1 | 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 commitBlobBlocks 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 CommitBlobBlocksOptions extends BlobServiceOptions 38 | { 39 | private $_contentType; 40 | private $_contentEncoding; 41 | private $_contentLanguage; 42 | private $_contentMD5; 43 | private $_cacheControl; 44 | private $_contentDisposition; 45 | private $_metadata; 46 | 47 | /** 48 | * Gets ContentType. 49 | * 50 | * @return string 51 | */ 52 | public function getContentType() 53 | { 54 | return $this->_contentType; 55 | } 56 | 57 | /** 58 | * Sets ContentType. 59 | * 60 | * @param string $contentType value. 61 | * 62 | * @return void 63 | */ 64 | public function setContentType($contentType) 65 | { 66 | $this->_contentType = $contentType; 67 | } 68 | 69 | /** 70 | * Gets ContentEncoding. 71 | * 72 | * @return string 73 | */ 74 | public function getContentEncoding() 75 | { 76 | return $this->_contentEncoding; 77 | } 78 | 79 | /** 80 | * Sets ContentEncoding. 81 | * 82 | * @param string $contentEncoding value. 83 | * 84 | * @return void 85 | */ 86 | public function setContentEncoding($contentEncoding) 87 | { 88 | $this->_contentEncoding = $contentEncoding; 89 | } 90 | 91 | /** 92 | * Gets ContentLanguage. 93 | * 94 | * @return string 95 | */ 96 | public function getContentLanguage() 97 | { 98 | return $this->_contentLanguage; 99 | } 100 | 101 | /** 102 | * Sets ContentLanguage. 103 | * 104 | * @param string $contentLanguage value. 105 | * 106 | * @return void 107 | */ 108 | public function setContentLanguage($contentLanguage) 109 | { 110 | $this->_contentLanguage = $contentLanguage; 111 | } 112 | 113 | /** 114 | * Gets ContentMD5. 115 | * 116 | * @return string 117 | */ 118 | public function getContentMD5() 119 | { 120 | return $this->_contentMD5; 121 | } 122 | 123 | /** 124 | * Sets ContentMD5. 125 | * 126 | * @param string $contentMD5 value. 127 | * 128 | * @return void 129 | */ 130 | public function setContentMD5($contentMD5) 131 | { 132 | $this->_contentMD5 = $contentMD5; 133 | } 134 | 135 | /** 136 | * Gets cache control. 137 | * 138 | * @return string 139 | */ 140 | public function getCacheControl() 141 | { 142 | return $this->_cacheControl; 143 | } 144 | 145 | /** 146 | * Sets cacheControl. 147 | * 148 | * @param string $cacheControl value to use. 149 | * 150 | * @return void 151 | */ 152 | public function setCacheControl($cacheControl) 153 | { 154 | $this->_cacheControl = $cacheControl; 155 | } 156 | 157 | /** 158 | * Gets content disposition. 159 | * 160 | * @return string 161 | */ 162 | public function getContentDisposition() 163 | { 164 | return $this->_contentDisposition; 165 | } 166 | 167 | /** 168 | * Sets contentDisposition. 169 | * 170 | * @param string $contentDisposition value to use. 171 | * 172 | * @return void 173 | */ 174 | public function setContentDisposition($contentDisposition) 175 | { 176 | $this->_contentDisposition = $contentDisposition; 177 | } 178 | 179 | /** 180 | * Gets blob metadata. 181 | * 182 | * @return array 183 | */ 184 | public function getMetadata() 185 | { 186 | return $this->_metadata; 187 | } 188 | 189 | /** 190 | * Sets blob metadata. 191 | * 192 | * @param array $metadata value. 193 | * 194 | * @return void 195 | */ 196 | public function setMetadata(array $metadata = null) 197 | { 198 | $this->_metadata = $metadata; 199 | } 200 | 201 | /** 202 | * Create a instance using the given options 203 | * @param mixed $options Input options 204 | * 205 | * @internal 206 | * 207 | * @return self 208 | */ 209 | public static function create($options) 210 | { 211 | $result = new CommitBlobBlocksOptions(); 212 | $result->setContentType($options->getContentType()); 213 | $result->setContentEncoding($options->getContentEncoding()); 214 | $result->setContentLanguage($options->getContentLanguage()); 215 | $result->setContentMD5($options->getContentMD5()); 216 | $result->setCacheControl($options->getCacheControl()); 217 | $result->setContentDisposition($options->getContentDisposition()); 218 | $result->setMetadata($options->getMetadata()); 219 | $result->setLeaseId($options->getLeaseId()); 220 | $result->setAccessConditions($options->getAccessConditions()); 221 | 222 | return $result; 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /src/Blob/Models/Container.php: -------------------------------------------------------------------------------- 1 | 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 | * WindowsAzure container object. 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 Container 38 | { 39 | private $_name; 40 | private $_url; 41 | private $_metadata; 42 | private $_properties; 43 | 44 | /** 45 | * Gets container name. 46 | * 47 | * @return string 48 | */ 49 | public function getName() 50 | { 51 | return $this->_name; 52 | } 53 | 54 | /** 55 | * Sets container name. 56 | * 57 | * @param string $name value. 58 | * 59 | * @return void 60 | */ 61 | public function setName($name) 62 | { 63 | $this->_name = $name; 64 | } 65 | 66 | /** 67 | * Gets container url. 68 | * 69 | * @return string 70 | */ 71 | public function getUrl() 72 | { 73 | return $this->_url; 74 | } 75 | 76 | /** 77 | * Sets container url. 78 | * 79 | * @param string $url value. 80 | * 81 | * @return void 82 | */ 83 | public function setUrl($url) 84 | { 85 | $this->_url = $url; 86 | } 87 | 88 | /** 89 | * Gets container metadata. 90 | * 91 | * @return array 92 | */ 93 | public function getMetadata() 94 | { 95 | return $this->_metadata; 96 | } 97 | 98 | /** 99 | * Sets container metadata. 100 | * 101 | * @param array $metadata value. 102 | * 103 | * @return void 104 | */ 105 | public function setMetadata(array $metadata = null) 106 | { 107 | $this->_metadata = $metadata; 108 | } 109 | 110 | /** 111 | * Gets container properties 112 | * 113 | * @return ContainerProperties 114 | */ 115 | public function getProperties() 116 | { 117 | return $this->_properties; 118 | } 119 | 120 | /** 121 | * Sets container properties 122 | * 123 | * @param ContainerProperties $properties container properties 124 | * 125 | * @return void 126 | */ 127 | public function setProperties(ContainerProperties $properties) 128 | { 129 | $this->_properties = $properties; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/Blob/Models/ContainerACL.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\ACLBase; 28 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 29 | use MicrosoftAzure\Storage\Common\Internal\Validate; 30 | 31 | /** 32 | * Holds container ACL members. 33 | * 34 | * @category Microsoft 35 | * @package MicrosoftAzure\Storage\Blob\Models 36 | * @author Azure Storage PHP SDK 37 | * @copyright 2016 Microsoft Corporation 38 | * @license https://github.com/azure/azure-storage-php/LICENSE 39 | * @link https://github.com/azure/azure-storage-php 40 | */ 41 | class ContainerACL extends ACLBase 42 | { 43 | private $publicAccess; 44 | 45 | /** 46 | * Constructor. 47 | */ 48 | public function __construct() 49 | { 50 | //setting the resource type to a default value. 51 | $this->setResourceType(Resources::RESOURCE_TYPE_CONTAINER); 52 | } 53 | 54 | /** 55 | * Parses the given array into signed identifiers and create an instance of 56 | * ContainerACL 57 | * 58 | * @param string $publicAccess The container public access. 59 | * @param array $parsed The parsed response into array representation. 60 | * 61 | * @internal 62 | * 63 | * @return ContainerACL 64 | */ 65 | public static function create($publicAccess, array $parsed = null) 66 | { 67 | Validate::isTrue( 68 | PublicAccessType::isValid($publicAccess), 69 | Resources::INVALID_BLOB_PAT_MSG 70 | ); 71 | $result = new ContainerACL(); 72 | $result->fromXmlArray($parsed); 73 | $result->setPublicAccess($publicAccess); 74 | 75 | return $result; 76 | } 77 | 78 | /** 79 | * Gets container publicAccess. 80 | * 81 | * @return string 82 | */ 83 | public function getPublicAccess() 84 | { 85 | return $this->publicAccess; 86 | } 87 | 88 | /** 89 | * Sets container publicAccess. 90 | * 91 | * @param string $publicAccess value. 92 | * 93 | * @return void 94 | */ 95 | public function setPublicAccess($publicAccess) 96 | { 97 | Validate::isTrue( 98 | PublicAccessType::isValid($publicAccess), 99 | Resources::INVALID_BLOB_PAT_MSG 100 | ); 101 | $this->publicAccess = $publicAccess; 102 | $this->setResourceType( 103 | self::getResourceTypeByPublicAccess($publicAccess) 104 | ); 105 | } 106 | 107 | /** 108 | * Gets the resource type according to the given public access. Default 109 | * value is Resources::RESOURCE_TYPE_CONTAINER. 110 | * 111 | * @param string $publicAccess The public access that determines the 112 | * resource type. 113 | * 114 | * @return string 115 | */ 116 | private static function getResourceTypeByPublicAccess($publicAccess) 117 | { 118 | $result = ''; 119 | 120 | switch ($publicAccess) { 121 | case PublicAccessType::BLOBS_ONLY: 122 | $result = Resources::RESOURCE_TYPE_BLOB; 123 | break; 124 | case PublicAccessType::CONTAINER_AND_BLOBS: 125 | $result = Resources::RESOURCE_TYPE_CONTAINER; 126 | break; 127 | default: 128 | $result = Resources::RESOURCE_TYPE_CONTAINER; 129 | break; 130 | } 131 | 132 | return $result; 133 | } 134 | 135 | /** 136 | * Validate if the resource type is for the class. 137 | * 138 | * @param string $resourceType the resource type to be validated. 139 | * 140 | * @throws \InvalidArgumentException 141 | * 142 | * @internal 143 | * 144 | * @return void 145 | */ 146 | protected static function validateResourceType($resourceType) 147 | { 148 | Validate::isTrue( 149 | $resourceType == Resources::RESOURCE_TYPE_BLOB || 150 | $resourceType == Resources::RESOURCE_TYPE_CONTAINER, 151 | Resources::INVALID_RESOURCE_TYPE 152 | ); 153 | } 154 | 155 | /** 156 | * Create a ContainerAccessPolicy object. 157 | * 158 | * @return ContainerAccessPolicy 159 | */ 160 | protected static function createAccessPolicy() 161 | { 162 | return new ContainerAccessPolicy(); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /src/Blob/Models/ContainerAccessPolicy.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2017 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources; 28 | use MicrosoftAzure\Storage\Common\Models\AccessPolicy; 29 | 30 | /** 31 | * Holds access policy elements 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2017 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class ContainerAccessPolicy extends AccessPolicy 41 | { 42 | /** 43 | * Get the valid permissions for the given resource. 44 | * 45 | * @return array 46 | */ 47 | public static function getResourceValidPermissions() 48 | { 49 | return BlobResources::ACCESS_PERMISSIONS[ 50 | BlobResources::RESOURCE_TYPE_CONTAINER 51 | ]; 52 | } 53 | 54 | /** 55 | * Constructor 56 | */ 57 | public function __construct() 58 | { 59 | parent::__construct(BlobResources::RESOURCE_TYPE_CONTAINER); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Blob/Models/ContainerProperties.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Validate; 29 | 30 | /** 31 | * Holds container properties fields 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class ContainerProperties 41 | { 42 | private $etag; 43 | private $lastModified; 44 | private $leaseDuration; 45 | private $leaseStatus; 46 | private $leaseState; 47 | private $publicAccess; 48 | 49 | /** 50 | * Gets container lastModified. 51 | * 52 | * @return \DateTime 53 | */ 54 | public function getLastModified() 55 | { 56 | return $this->lastModified; 57 | } 58 | 59 | /** 60 | * Sets container lastModified. 61 | * 62 | * @param \DateTime $lastModified value. 63 | * 64 | * @return void 65 | */ 66 | public function setLastModified(\DateTime $lastModified) 67 | { 68 | $this->lastModified = $lastModified; 69 | } 70 | 71 | /** 72 | * Gets container etag. 73 | * 74 | * @return string 75 | */ 76 | public function getETag() 77 | { 78 | return $this->etag; 79 | } 80 | 81 | /** 82 | * Sets container etag. 83 | * 84 | * @param string $etag value. 85 | * 86 | * @return void 87 | */ 88 | public function setETag($etag) 89 | { 90 | $this->etag = $etag; 91 | } 92 | 93 | /** 94 | * Gets blob leaseStatus. 95 | * 96 | * @return string 97 | */ 98 | public function getLeaseStatus() 99 | { 100 | return $this->leaseStatus; 101 | } 102 | 103 | /** 104 | * Sets blob leaseStatus. 105 | * 106 | * @param string $leaseStatus value. 107 | * 108 | * @return void 109 | */ 110 | public function setLeaseStatus($leaseStatus) 111 | { 112 | $this->leaseStatus = $leaseStatus; 113 | } 114 | 115 | /** 116 | * Gets blob lease state. 117 | * 118 | * @return string 119 | */ 120 | public function getLeaseState() 121 | { 122 | return $this->leaseState; 123 | } 124 | 125 | /** 126 | * Sets blob lease state. 127 | * 128 | * @param string $leaseState value. 129 | * 130 | * @return void 131 | */ 132 | public function setLeaseState($leaseState) 133 | { 134 | $this->leaseState = $leaseState; 135 | } 136 | 137 | /** 138 | * Gets blob lease duration. 139 | * 140 | * @return string 141 | */ 142 | public function getLeaseDuration() 143 | { 144 | return $this->leaseDuration; 145 | } 146 | 147 | /** 148 | * Sets blob leaseStatus. 149 | * 150 | * @param string $leaseDuration value. 151 | * 152 | * @return void 153 | */ 154 | public function setLeaseDuration($leaseDuration) 155 | { 156 | $this->leaseDuration = $leaseDuration; 157 | } 158 | 159 | /** 160 | * Gets container publicAccess. 161 | * 162 | * @return string 163 | */ 164 | public function getPublicAccess() 165 | { 166 | return $this->publicAccess; 167 | } 168 | 169 | /** 170 | * Sets container publicAccess. 171 | * 172 | * @param string $publicAccess value. 173 | * 174 | * @return void 175 | */ 176 | public function setPublicAccess($publicAccess) 177 | { 178 | Validate::isTrue( 179 | PublicAccessType::isValid($publicAccess), 180 | Resources::INVALID_BLOB_PAT_MSG 181 | ); 182 | $this->publicAccess = $publicAccess; 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /src/Blob/Models/CopyBlobFromURLOptions.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2017 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 CopyBlobOptions wrapper 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 33 | * @copyright 2017 Microsoft Corporation 34 | * @license https://github.com/azure/azure-storage-php/LICENSE 35 | * @link https://github.com/azure/azure-storage-php 36 | */ 37 | class CopyBlobFromURLOptions extends BlobServiceOptions 38 | { 39 | use AccessTierTrait; 40 | 41 | private $sourceLeaseId; 42 | private $sourceAccessConditions; 43 | private $metadata; 44 | private $isIncrementalCopy; 45 | 46 | /** 47 | * Gets source access condition 48 | * 49 | * @return AccessCondition[] 50 | */ 51 | public function getSourceAccessConditions() 52 | { 53 | return $this->sourceAccessConditions; 54 | } 55 | 56 | /** 57 | * Sets source access condition 58 | * 59 | * @param array $sourceAccessConditions value to use. 60 | * 61 | * @return void 62 | */ 63 | public function setSourceAccessConditions($sourceAccessConditions) 64 | { 65 | if (!is_null($sourceAccessConditions) && 66 | is_array($sourceAccessConditions)) { 67 | $this->sourceAccessConditions = $sourceAccessConditions; 68 | } else { 69 | $this->sourceAccessConditions = [$sourceAccessConditions]; 70 | } 71 | } 72 | 73 | /** 74 | * Gets metadata. 75 | * 76 | * @return array 77 | */ 78 | public function getMetadata() 79 | { 80 | return $this->metadata; 81 | } 82 | 83 | /** 84 | * Sets metadata. 85 | * 86 | * @param array $metadata value. 87 | * 88 | * @return void 89 | */ 90 | public function setMetadata(array $metadata) 91 | { 92 | $this->metadata = $metadata; 93 | } 94 | 95 | /** 96 | * Gets source lease ID. 97 | * 98 | * @return string 99 | */ 100 | public function getSourceLeaseId() 101 | { 102 | return $this->sourceLeaseId; 103 | } 104 | 105 | /** 106 | * Sets source lease ID. 107 | * 108 | * @param string $sourceLeaseId value. 109 | * 110 | * @return void 111 | */ 112 | public function setSourceLeaseId($sourceLeaseId) 113 | { 114 | $this->sourceLeaseId = $sourceLeaseId; 115 | } 116 | 117 | /** 118 | * Gets isIncrementalCopy. 119 | * 120 | * @return boolean 121 | */ 122 | public function getIsIncrementalCopy() 123 | { 124 | return $this->isIncrementalCopy; 125 | } 126 | 127 | /** 128 | * Sets isIncrementalCopy. 129 | * 130 | * @param boolean $isIncrementalCopy 131 | * 132 | * @return void 133 | */ 134 | public function setIsIncrementalCopy($isIncrementalCopy) 135 | { 136 | $this->isIncrementalCopy = $isIncrementalCopy; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/Blob/Models/CopyBlobOptions.php: -------------------------------------------------------------------------------- 1 | 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 CopyBlobOptions wrapper 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 CopyBlobOptions extends CopyBlobFromURLOptions 38 | { 39 | private $sourceSnapshot; 40 | 41 | /** 42 | * Gets source snapshot. 43 | * 44 | * @return string 45 | */ 46 | public function getSourceSnapshot() 47 | { 48 | return $this->sourceSnapshot; 49 | } 50 | 51 | /** 52 | * Sets source snapshot. 53 | * 54 | * @param string $sourceSnapshot value. 55 | * 56 | * @return void 57 | */ 58 | public function setSourceSnapshot($sourceSnapshot) 59 | { 60 | $this->sourceSnapshot = $sourceSnapshot; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Blob/Models/CopyBlobResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | 30 | /** 31 | * The result of calling copyBlob API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class CopyBlobResult 41 | { 42 | private $_etag; 43 | private $_lastModified; 44 | private $_copyId; 45 | private $_copyStatus; 46 | 47 | /** 48 | * Creates CopyBlobResult object from the response of the copy blob request. 49 | * 50 | * @param array $headers The HTTP response headers in array representation. 51 | * 52 | * @internal 53 | * 54 | * @return CopyBlobResult 55 | */ 56 | public static function create(array $headers) 57 | { 58 | $result = new CopyBlobResult(); 59 | $result->setETag( 60 | Utilities::tryGetValueInsensitive( 61 | Resources::ETAG, 62 | $headers 63 | ) 64 | ); 65 | $result->setCopyId( 66 | Utilities::tryGetValueInsensitive( 67 | Resources::X_MS_COPY_ID, 68 | $headers 69 | ) 70 | ); 71 | $result->setCopyStatus( 72 | Utilities::tryGetValueInsensitive( 73 | Resources::X_MS_COPY_STATUS, 74 | $headers 75 | ) 76 | ); 77 | if (Utilities::arrayKeyExistsInsensitive(Resources::LAST_MODIFIED, $headers)) { 78 | $lastModified = Utilities::tryGetValueInsensitive( 79 | Resources::LAST_MODIFIED, 80 | $headers 81 | ); 82 | $result->setLastModified(Utilities::rfc1123ToDateTime($lastModified)); 83 | } 84 | 85 | return $result; 86 | } 87 | 88 | /** 89 | * Gets copy Id 90 | * 91 | * @return string 92 | */ 93 | public function getCopyId() 94 | { 95 | return $this->_copyId; 96 | } 97 | 98 | /** 99 | * Sets copy Id 100 | * 101 | * @param string $copyId the blob copy id. 102 | * 103 | * @internal 104 | * 105 | * @return void 106 | */ 107 | protected function setCopyId($copyId) 108 | { 109 | $this->_copyId = $copyId; 110 | } 111 | 112 | /** 113 | * Gets copy status 114 | * 115 | * @return string 116 | */ 117 | public function getCopyStatus() 118 | { 119 | return $this->_copyStatus; 120 | } 121 | 122 | /** 123 | * Sets copy status 124 | * 125 | * @param string $status the copy status. 126 | * 127 | * @internal 128 | * 129 | * @return void 130 | */ 131 | protected function setCopyStatus($copystatus) 132 | { 133 | $this->_copyStatus = $copystatus; 134 | } 135 | 136 | /** 137 | * Gets ETag. 138 | * 139 | * @return string 140 | */ 141 | public function getETag() 142 | { 143 | return $this->_etag; 144 | } 145 | 146 | /** 147 | * Sets ETag. 148 | * 149 | * @param string $etag value. 150 | * 151 | * @return void 152 | */ 153 | protected function setETag($etag) 154 | { 155 | $this->_etag = $etag; 156 | } 157 | 158 | /** 159 | * Gets blob lastModified. 160 | * 161 | * @return \DateTime 162 | */ 163 | public function getLastModified() 164 | { 165 | return $this->_lastModified; 166 | } 167 | 168 | /** 169 | * Sets blob lastModified. 170 | * 171 | * @param \DateTime $lastModified value. 172 | * 173 | * @return void 174 | */ 175 | protected function setLastModified(\DateTime $lastModified) 176 | { 177 | $this->_lastModified = $lastModified; 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateBlobBlockOptions.php: -------------------------------------------------------------------------------- 1 | 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 createBlobBlock wrapper 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 CreateBlobBlockOptions extends BlobServiceOptions 38 | { 39 | private $_contentMD5; 40 | private $_numberOfConcurrency; 41 | 42 | /** 43 | * Gets blob contentMD5. 44 | * 45 | * @return string 46 | */ 47 | public function getContentMD5() 48 | { 49 | return $this->_contentMD5; 50 | } 51 | 52 | /** 53 | * Sets blob contentMD5. 54 | * 55 | * @param string $contentMD5 value. 56 | * 57 | * @return void 58 | */ 59 | public function setContentMD5($contentMD5) 60 | { 61 | $this->_contentMD5 = $contentMD5; 62 | } 63 | 64 | /** 65 | * Gets number of concurrency for sending a blob. 66 | * 67 | * @return int 68 | */ 69 | public function getNumberOfConcurrency() 70 | { 71 | return $this->_numberOfConcurrency; 72 | } 73 | 74 | /** 75 | * Sets number of concurrency for sending a blob. 76 | * 77 | * @param int $numberOfConcurrency the number of concurrent requests. 78 | */ 79 | public function setNumberOfConcurrency($numberOfConcurrency) 80 | { 81 | $this->_numberOfConcurrency = $numberOfConcurrency; 82 | } 83 | 84 | /** 85 | * Construct a CreateBlobBlockOptions object from a createBlobOptions. 86 | * 87 | * @param CreateBlobOptions $createBlobOptions 88 | * 89 | * @return CreateBlobBlockOptions 90 | */ 91 | public static function create(CreateBlobOptions $createBlobOptions) 92 | { 93 | $result = new CreateBlobBlockOptions(); 94 | $result->setTimeout($createBlobOptions->getTimeout()); 95 | $result->setLeaseId($createBlobOptions->getLeaseId()); 96 | $result->setNumberOfConcurrency( 97 | $createBlobOptions->getNumberOfConcurrency() 98 | ); 99 | return $result; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateBlobOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | 29 | /** 30 | * optional parameters for createXXXBlob wrapper 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class CreateBlobOptions extends BlobServiceOptions 40 | { 41 | private $_contentType; 42 | private $_contentEncoding; 43 | private $_contentLanguage; 44 | private $_contentMD5; 45 | private $_cacheControl; 46 | private $_contentDisposition; 47 | private $_metadata; 48 | private $_sequenceNumber; 49 | private $_numberOfConcurrency; 50 | 51 | /** 52 | * Gets blob contentType. 53 | * 54 | * @return string 55 | */ 56 | public function getContentType() 57 | { 58 | return $this->_contentType; 59 | } 60 | 61 | /** 62 | * Sets blob contentType. 63 | * 64 | * @param string $contentType value. 65 | * 66 | * @return void 67 | */ 68 | public function setContentType($contentType) 69 | { 70 | $this->_contentType = $contentType; 71 | } 72 | 73 | /** 74 | * Gets contentEncoding. 75 | * 76 | * @return string 77 | */ 78 | public function getContentEncoding() 79 | { 80 | return $this->_contentEncoding; 81 | } 82 | 83 | /** 84 | * Sets contentEncoding. 85 | * 86 | * @param string $contentEncoding value. 87 | * 88 | * @return void 89 | */ 90 | public function setContentEncoding($contentEncoding) 91 | { 92 | $this->_contentEncoding = $contentEncoding; 93 | } 94 | 95 | /** 96 | * Gets contentLanguage. 97 | * 98 | * @return string 99 | */ 100 | public function getContentLanguage() 101 | { 102 | return $this->_contentLanguage; 103 | } 104 | 105 | /** 106 | * Sets contentLanguage. 107 | * 108 | * @param string $contentLanguage value. 109 | * 110 | * @return void 111 | */ 112 | public function setContentLanguage($contentLanguage) 113 | { 114 | $this->_contentLanguage = $contentLanguage; 115 | } 116 | 117 | /** 118 | * Gets contentMD5. 119 | * 120 | * @return string 121 | */ 122 | public function getContentMD5() 123 | { 124 | return $this->_contentMD5; 125 | } 126 | 127 | /** 128 | * Sets contentMD5. 129 | * 130 | * @param string $contentMD5 value. 131 | * 132 | * @return void 133 | */ 134 | public function setContentMD5($contentMD5) 135 | { 136 | $this->_contentMD5 = $contentMD5; 137 | } 138 | 139 | /** 140 | * Gets cacheControl. 141 | * 142 | * @return string 143 | */ 144 | public function getCacheControl() 145 | { 146 | return $this->_cacheControl; 147 | } 148 | 149 | /** 150 | * Sets cacheControl. 151 | * 152 | * @param string $cacheControl value to use. 153 | * 154 | * @return void 155 | */ 156 | public function setCacheControl($cacheControl) 157 | { 158 | $this->_cacheControl = $cacheControl; 159 | } 160 | 161 | /** 162 | * Gets content disposition. 163 | * 164 | * @return string 165 | */ 166 | public function getContentDisposition() 167 | { 168 | return $this->_contentDisposition; 169 | } 170 | 171 | /** 172 | * Sets content disposition. 173 | * 174 | * @param string $contentDisposition value to use. 175 | * 176 | * @return void 177 | */ 178 | public function setContentDisposition($contentDisposition) 179 | { 180 | $this->_contentDisposition = $contentDisposition; 181 | } 182 | 183 | /** 184 | * Gets blob metadata. 185 | * 186 | * @return array 187 | */ 188 | public function getMetadata() 189 | { 190 | return $this->_metadata; 191 | } 192 | 193 | /** 194 | * Sets blob metadata. 195 | * 196 | * @param array $metadata value. 197 | * 198 | * @return void 199 | */ 200 | public function setMetadata(array $metadata) 201 | { 202 | $this->_metadata = $metadata; 203 | } 204 | 205 | /** 206 | * Gets blob sequenceNumber. 207 | * 208 | * @return int 209 | */ 210 | public function getSequenceNumber() 211 | { 212 | return $this->_sequenceNumber; 213 | } 214 | 215 | /** 216 | * Sets blob sequenceNumber. 217 | * 218 | * @param int $sequenceNumber value. 219 | * 220 | * @return void 221 | */ 222 | public function setSequenceNumber($sequenceNumber) 223 | { 224 | Validate::isInteger($sequenceNumber, 'sequenceNumber'); 225 | $this->_sequenceNumber = $sequenceNumber; 226 | } 227 | 228 | /** 229 | * Gets number of concurrency for sending a blob. 230 | * 231 | * @return int 232 | */ 233 | public function getNumberOfConcurrency() 234 | { 235 | return $this->_numberOfConcurrency; 236 | } 237 | 238 | /** 239 | * Sets number of concurrency for sending a blob. 240 | * 241 | * @param int $numberOfConcurrency the number of concurrent requests. 242 | */ 243 | public function setNumberOfConcurrency($numberOfConcurrency) 244 | { 245 | $this->_numberOfConcurrency = $numberOfConcurrency; 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateBlobPagesOptions.php: -------------------------------------------------------------------------------- 1 | 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 create and clear blob pages 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 CreateBlobPagesOptions extends BlobServiceOptions 38 | { 39 | private $_contentMD5; 40 | 41 | /** 42 | * Gets blob contentMD5. 43 | * 44 | * @return string 45 | */ 46 | public function getContentMD5() 47 | { 48 | return $this->_contentMD5; 49 | } 50 | 51 | /** 52 | * Sets blob contentMD5. 53 | * 54 | * @param string $contentMD5 value. 55 | * 56 | * @return void 57 | */ 58 | public function setContentMD5($contentMD5) 59 | { 60 | $this->_contentMD5 = $contentMD5; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateBlobPagesResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Validate; 29 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 30 | 31 | /** 32 | * Holds result of calling create or clear blob pages 33 | * 34 | * @category Microsoft 35 | * @package MicrosoftAzure\Storage\Blob\Models 36 | * @author Azure Storage PHP SDK 37 | * @copyright 2016 Microsoft Corporation 38 | * @license https://github.com/azure/azure-storage-php/LICENSE 39 | * @link https://github.com/azure/azure-storage-php 40 | */ 41 | class CreateBlobPagesResult 42 | { 43 | private $contentMD5; 44 | private $etag; 45 | private $lastModified; 46 | private $requestServerEncrypted; 47 | private $sequenceNumber; 48 | 49 | /** 50 | * Creates CreateBlobPagesResult object from $parsed response in array 51 | * representation 52 | * 53 | * @param array $headers HTTP response headers 54 | * 55 | * @internal 56 | * 57 | * @return CreateBlobPagesResult 58 | */ 59 | public static function create(array $headers) 60 | { 61 | $result = new CreateBlobPagesResult(); 62 | $clean = array_change_key_case($headers); 63 | 64 | $date = $clean[Resources::LAST_MODIFIED]; 65 | $date = Utilities::rfc1123ToDateTime($date); 66 | $result->setETag($clean[Resources::ETAG]); 67 | $result->setLastModified($date); 68 | 69 | $result->setContentMD5( 70 | Utilities::tryGetValue($clean, Resources::CONTENT_MD5) 71 | ); 72 | 73 | $result->setRequestServerEncrypted( 74 | Utilities::toBoolean( 75 | Utilities::tryGetValueInsensitive( 76 | Resources::X_MS_REQUEST_SERVER_ENCRYPTED, 77 | $headers 78 | ), 79 | true 80 | ) 81 | ); 82 | 83 | $result->setSequenceNumber( 84 | intval( 85 | Utilities::tryGetValue( 86 | $clean, 87 | Resources::X_MS_BLOB_SEQUENCE_NUMBER 88 | ) 89 | ) 90 | ); 91 | 92 | return $result; 93 | } 94 | 95 | /** 96 | * Gets blob lastModified. 97 | * 98 | * @return \DateTime. 99 | */ 100 | public function getLastModified() 101 | { 102 | return $this->lastModified; 103 | } 104 | 105 | /** 106 | * Sets blob lastModified. 107 | * 108 | * @param \DateTime $lastModified value. 109 | * 110 | * @return void 111 | */ 112 | protected function setLastModified($lastModified) 113 | { 114 | Validate::isDate($lastModified); 115 | $this->lastModified = $lastModified; 116 | } 117 | 118 | /** 119 | * Gets blob etag. 120 | * 121 | * @return string 122 | */ 123 | public function getETag() 124 | { 125 | return $this->etag; 126 | } 127 | 128 | /** 129 | * Sets blob etag. 130 | * 131 | * @param string $etag value. 132 | * 133 | * @return void 134 | */ 135 | protected function setETag($etag) 136 | { 137 | Validate::canCastAsString($etag, 'etag'); 138 | $this->etag = $etag; 139 | } 140 | 141 | /** 142 | * Gets blob contentMD5. 143 | * 144 | * @return string 145 | */ 146 | public function getContentMD5() 147 | { 148 | return $this->contentMD5; 149 | } 150 | 151 | /** 152 | * Sets blob contentMD5. 153 | * 154 | * @param string $contentMD5 value. 155 | * 156 | * @return void 157 | */ 158 | protected function setContentMD5($contentMD5) 159 | { 160 | $this->contentMD5 = $contentMD5; 161 | } 162 | 163 | /** 164 | * Gets the whether the contents of the request are successfully encrypted. 165 | * 166 | * @return boolean 167 | */ 168 | public function getRequestServerEncrypted() 169 | { 170 | return $this->requestServerEncrypted; 171 | } 172 | 173 | /** 174 | * Sets the request server encryption value. 175 | * 176 | * @param boolean $requestServerEncrypted 177 | * 178 | * @return void 179 | */ 180 | public function setRequestServerEncrypted($requestServerEncrypted) 181 | { 182 | $this->requestServerEncrypted = $requestServerEncrypted; 183 | } 184 | 185 | /** 186 | * Gets blob sequenceNumber. 187 | * 188 | * @return int 189 | */ 190 | public function getSequenceNumber() 191 | { 192 | return $this->sequenceNumber; 193 | } 194 | 195 | /** 196 | * Sets blob sequenceNumber. 197 | * 198 | * @param int $sequenceNumber value. 199 | * 200 | * @return void 201 | */ 202 | protected function setSequenceNumber($sequenceNumber) 203 | { 204 | Validate::isInteger($sequenceNumber, 'sequenceNumber'); 205 | $this->sequenceNumber = $sequenceNumber; 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateBlobSnapshotOptions.php: -------------------------------------------------------------------------------- 1 | 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 | * The optional parameters for createBlobSnapshot wrapper. 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 CreateBlobSnapshotOptions extends BlobServiceOptions 38 | { 39 | private $_metadata; 40 | 41 | /** 42 | * Gets metadata. 43 | * 44 | * @return array 45 | */ 46 | public function getMetadata() 47 | { 48 | return $this->_metadata; 49 | } 50 | 51 | /** 52 | * Sets metadata. 53 | * 54 | * @param array $metadata The metadata array. 55 | * 56 | * @return void 57 | */ 58 | public function setMetadata(array $metadata) 59 | { 60 | $this->_metadata = $metadata; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateBlobSnapshotResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | 30 | /** 31 | * The result of creating Blob snapshot. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class CreateBlobSnapshotResult 41 | { 42 | private $_snapshot; 43 | private $_etag; 44 | private $_lastModified; 45 | 46 | /** 47 | * Creates CreateBlobSnapshotResult object from the response of the 48 | * create Blob snapshot request. 49 | * 50 | * @param array $headers The HTTP response headers in array representation. 51 | * 52 | * @internal 53 | * 54 | * @return CreateBlobSnapshotResult 55 | */ 56 | public static function create(array $headers) 57 | { 58 | $result = new CreateBlobSnapshotResult(); 59 | $headerWithLowerCaseKey = array_change_key_case($headers); 60 | 61 | $result->setETag($headerWithLowerCaseKey[Resources::ETAG]); 62 | 63 | $result->setLastModified( 64 | Utilities::rfc1123ToDateTime( 65 | $headerWithLowerCaseKey[Resources::LAST_MODIFIED] 66 | ) 67 | ); 68 | 69 | $result->setSnapshot($headerWithLowerCaseKey[Resources::X_MS_SNAPSHOT]); 70 | 71 | return $result; 72 | } 73 | 74 | /** 75 | * Gets snapshot. 76 | * 77 | * @return string 78 | */ 79 | public function getSnapshot() 80 | { 81 | return $this->_snapshot; 82 | } 83 | 84 | /** 85 | * Sets snapshot. 86 | * 87 | * @param string $snapshot value. 88 | * 89 | * @return void 90 | */ 91 | protected function setSnapshot($snapshot) 92 | { 93 | $this->_snapshot = $snapshot; 94 | } 95 | 96 | /** 97 | * Gets ETag. 98 | * 99 | * @return string 100 | */ 101 | public function getETag() 102 | { 103 | return $this->_etag; 104 | } 105 | 106 | /** 107 | * Sets ETag. 108 | * 109 | * @param string $etag value. 110 | * 111 | * @return void 112 | */ 113 | protected function setETag($etag) 114 | { 115 | $this->_etag = $etag; 116 | } 117 | 118 | /** 119 | * Gets blob lastModified. 120 | * 121 | * @return \DateTime 122 | */ 123 | public function getLastModified() 124 | { 125 | return $this->_lastModified; 126 | } 127 | 128 | /** 129 | * Sets blob lastModified. 130 | * 131 | * @param \DateTime $lastModified value. 132 | * 133 | * @return void 134 | */ 135 | protected function setLastModified($lastModified) 136 | { 137 | $this->_lastModified = $lastModified; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateBlockBlobOptions.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2018 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 | use MicrosoftAzure\Storage\Common\Models\TransactionalMD5Trait; 28 | 29 | /** 30 | * Optional parameters for CreateBlockBlob. 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2018 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class CreateBlockBlobOptions extends CreateBlobOptions 40 | { 41 | use TransactionalMD5Trait; 42 | } 43 | -------------------------------------------------------------------------------- /src/Blob/Models/CreateContainerOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | 29 | /** 30 | * Optional parameters for createContainer API 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class CreateContainerOptions extends BlobServiceOptions 40 | { 41 | private $_publicAccess; 42 | private $_metadata; 43 | 44 | /** 45 | * Gets container public access. 46 | * 47 | * @return string 48 | */ 49 | public function getPublicAccess() 50 | { 51 | return $this->_publicAccess; 52 | } 53 | 54 | /** 55 | * Specifies whether data in the container may be accessed publicly and the level 56 | * of access. Possible values include: 57 | * 1) container: Specifies full public read access for container and blob data. 58 | * Clients can enumerate blobs within the container via anonymous request, but 59 | * cannot enumerate containers within the storage account. 60 | * 2) blob: Specifies public read access for blobs. Blob data within this 61 | * container can be read via anonymous request, but container data is not 62 | * available. Clients cannot enumerate blobs within the container via 63 | * anonymous request. 64 | * If this value is not specified in the request, container data is private to 65 | * the account owner. 66 | * 67 | * @param string $publicAccess access modifier for the container 68 | * 69 | * @return void 70 | */ 71 | public function setPublicAccess($publicAccess) 72 | { 73 | Validate::canCastAsString($publicAccess, 'publicAccess'); 74 | $this->_publicAccess = $publicAccess; 75 | } 76 | 77 | /** 78 | * Gets user defined metadata. 79 | * 80 | * @return array 81 | */ 82 | public function getMetadata() 83 | { 84 | return $this->_metadata; 85 | } 86 | 87 | /** 88 | * Sets user defined metadata. This metadata should be added without the header 89 | * prefix (x-ms-meta-*). 90 | * 91 | * @param array $metadata user defined metadata object in array form. 92 | * 93 | * @return void 94 | */ 95 | public function setMetadata(array $metadata) 96 | { 97 | $this->_metadata = $metadata; 98 | } 99 | 100 | /** 101 | * Adds new metadata element. This element should be added without the header 102 | * prefix (x-ms-meta-*). 103 | * 104 | * @param string $key metadata key element. 105 | * @param string $value metadata value element. 106 | * 107 | * @return void 108 | */ 109 | public function addMetadata($key, $value) 110 | { 111 | $this->_metadata[$key] = $value; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/Blob/Models/CreatePageBlobFromContentOptions.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2018 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 | use MicrosoftAzure\Storage\Common\Models\TransactionalMD5Trait; 28 | 29 | /** 30 | * Optional parameters for createPageBlobFromContent. 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2018 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class CreatePageBlobFromContentOptions extends CreatePageBlobOptions 40 | { 41 | use TransactionalMD5Trait; 42 | } 43 | -------------------------------------------------------------------------------- /src/Blob/Models/CreatePageBlobOptions.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2018 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 CreatePageBlob. 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 33 | * @copyright 2018 Microsoft Corporation 34 | * @license https://github.com/azure/azure-storage-php/LICENSE 35 | * @link https://github.com/azure/azure-storage-php 36 | */ 37 | class CreatePageBlobOptions extends CreateBlobOptions 38 | { 39 | use AccessTierTrait; 40 | } 41 | -------------------------------------------------------------------------------- /src/Blob/Models/DeleteBlobOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | 29 | /** 30 | * Optional parameters for deleteBlob wrapper 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class DeleteBlobOptions extends BlobServiceOptions 40 | { 41 | private $_snapshot; 42 | private $_deleteSnaphotsOnly; 43 | 44 | /** 45 | * Gets blob snapshot. 46 | * 47 | * @return string 48 | */ 49 | public function getSnapshot() 50 | { 51 | return $this->_snapshot; 52 | } 53 | 54 | /** 55 | * Sets blob snapshot. 56 | * 57 | * @param string $snapshot value. 58 | * 59 | * @return void 60 | */ 61 | public function setSnapshot($snapshot) 62 | { 63 | $this->_snapshot = $snapshot; 64 | } 65 | 66 | /** 67 | * Gets blob deleteSnaphotsOnly. 68 | * 69 | * @return boolean 70 | */ 71 | public function getDeleteSnaphotsOnly() 72 | { 73 | return $this->_deleteSnaphotsOnly; 74 | } 75 | 76 | /** 77 | * Sets blob deleteSnaphotsOnly. 78 | * 79 | * @param string $deleteSnaphotsOnly value. 80 | * 81 | * @return boolean 82 | */ 83 | public function setDeleteSnaphotsOnly($deleteSnaphotsOnly) 84 | { 85 | Validate::isBoolean($deleteSnaphotsOnly); 86 | $this->_deleteSnaphotsOnly = $deleteSnaphotsOnly; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/Blob/Models/GetBlobMetadataOptions.php: -------------------------------------------------------------------------------- 1 | 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 getBlobMetadata wrapper 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 GetBlobMetadataOptions extends BlobServiceOptions 38 | { 39 | private $_snapshot; 40 | 41 | /** 42 | * Gets blob snapshot. 43 | * 44 | * @return string 45 | */ 46 | public function getSnapshot() 47 | { 48 | return $this->_snapshot; 49 | } 50 | 51 | /** 52 | * Sets blob snapshot. 53 | * 54 | * @param string $snapshot value. 55 | * 56 | * @return void 57 | */ 58 | public function setSnapshot($snapshot) 59 | { 60 | $this->_snapshot = $snapshot; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Blob/Models/GetBlobMetadataResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\MetadataTrait; 28 | 29 | /** 30 | * Holds results of calling getBlobMetadata wrapper 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class GetBlobMetadataResult 40 | { 41 | use MetadataTrait; 42 | 43 | /** 44 | * Creates the instance from the parsed headers. 45 | * 46 | * @param array $parsed Parsed headers 47 | * 48 | * @return GetBlobMetadataResult 49 | */ 50 | public static function create(array $parsed) 51 | { 52 | return static::createMetadataResult($parsed); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Blob/Models/GetBlobOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | use MicrosoftAzure\Storage\Common\Models\Range; 29 | 30 | /** 31 | * Optional parameters for getBlob wrapper 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class GetBlobOptions extends BlobServiceOptions 41 | { 42 | private $snapshot; 43 | private $range; 44 | private $rangeGetContentMD5; 45 | 46 | /** 47 | * Gets blob snapshot. 48 | * 49 | * @return string 50 | */ 51 | public function getSnapshot() 52 | { 53 | return $this->snapshot; 54 | } 55 | 56 | /** 57 | * Sets blob snapshot. 58 | * 59 | * @param string $snapshot value. 60 | * 61 | * @return void 62 | */ 63 | public function setSnapshot($snapshot) 64 | { 65 | $this->snapshot = $snapshot; 66 | } 67 | 68 | /** 69 | * Gets Blob range. 70 | * 71 | * @return Range 72 | */ 73 | public function getRange() 74 | { 75 | return $this->range; 76 | } 77 | 78 | /** 79 | * Sets Blob range. 80 | * 81 | * @param Range $range value. 82 | * 83 | * @return void 84 | */ 85 | public function setRange(Range $range) 86 | { 87 | $this->range = $range; 88 | } 89 | 90 | /** 91 | * Gets rangeGetContentMD5 92 | * 93 | * @return boolean 94 | */ 95 | public function getRangeGetContentMD5() 96 | { 97 | return $this->rangeGetContentMD5; 98 | } 99 | 100 | /** 101 | * Sets rangeGetContentMD5 102 | * 103 | * @param boolean $rangeGetContentMD5 value 104 | * 105 | * @return void 106 | */ 107 | public function setRangeGetContentMD5($rangeGetContentMD5) 108 | { 109 | Validate::isBoolean($rangeGetContentMD5); 110 | $this->rangeGetContentMD5 = $rangeGetContentMD5; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/Blob/Models/GetBlobPropertiesOptions.php: -------------------------------------------------------------------------------- 1 | 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 getBlobProperties wrapper 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 GetBlobPropertiesOptions extends BlobServiceOptions 38 | { 39 | private $_snapshot; 40 | 41 | /** 42 | * Gets blob snapshot. 43 | * 44 | * @return string 45 | */ 46 | public function getSnapshot() 47 | { 48 | return $this->_snapshot; 49 | } 50 | 51 | /** 52 | * Sets blob snapshot. 53 | * 54 | * @param string $snapshot value. 55 | * 56 | * @return void 57 | */ 58 | public function setSnapshot($snapshot) 59 | { 60 | $this->_snapshot = $snapshot; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Blob/Models/GetBlobPropertiesResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\MetadataTrait; 28 | 29 | /** 30 | * Holds result of calling getBlobProperties 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class GetBlobPropertiesResult 40 | { 41 | use MetadataTrait; 42 | 43 | private $_properties; 44 | 45 | /** 46 | * Gets blob properties. 47 | * 48 | * @return BlobProperties 49 | */ 50 | public function getProperties() 51 | { 52 | return $this->_properties; 53 | } 54 | 55 | /** 56 | * Sets blob properties. 57 | * 58 | * @param BlobProperties $properties value. 59 | * 60 | * @return void 61 | */ 62 | protected function setProperties($properties) 63 | { 64 | $this->_properties = $properties; 65 | } 66 | 67 | /** 68 | * Create a instance using the given headers. 69 | * 70 | * @param array $headers response headers parsed in an array 71 | * 72 | * @internal 73 | * 74 | * @return GetBlobPropertiesResult 75 | */ 76 | public static function create(array $headers) 77 | { 78 | $result = static::createMetadataResult($headers); 79 | 80 | $result->setProperties(BlobProperties::createFromHttpHeaders($headers)); 81 | 82 | return $result; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/Blob/Models/GetBlobResult.php: -------------------------------------------------------------------------------- 1 | 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 | use Psr\Http\Message\StreamInterface; 28 | 29 | /** 30 | * Holds result of GetBlob API. 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class GetBlobResult 40 | { 41 | private $properties; 42 | private $metadata; 43 | private $contentStream; 44 | 45 | /** 46 | * Creates GetBlobResult from getBlob call. 47 | * 48 | * @param array $headers The HTTP response headers. 49 | * @param StreamInterface $body The response body. 50 | * @param array $metadata The blob metadata. 51 | * 52 | * @internal 53 | * 54 | * @return GetBlobResult 55 | */ 56 | public static function create( 57 | array $headers, 58 | StreamInterface $body, 59 | array $metadata 60 | ) { 61 | $result = new GetBlobResult(); 62 | $result->setContentStream($body->detach()); 63 | $result->setProperties(BlobProperties::createFromHttpHeaders($headers)); 64 | $result->setMetadata(is_null($metadata) ? array() : $metadata); 65 | 66 | return $result; 67 | } 68 | 69 | /** 70 | * Gets blob metadata. 71 | * 72 | * @return array 73 | */ 74 | public function getMetadata() 75 | { 76 | return $this->metadata; 77 | } 78 | 79 | /** 80 | * Sets blob metadata. 81 | * 82 | * @param array $metadata value. 83 | * 84 | * @return void 85 | */ 86 | protected function setMetadata(array $metadata) 87 | { 88 | $this->metadata = $metadata; 89 | } 90 | 91 | /** 92 | * Gets blob properties. 93 | * 94 | * @return BlobProperties 95 | */ 96 | public function getProperties() 97 | { 98 | return $this->properties; 99 | } 100 | 101 | /** 102 | * Sets blob properties. 103 | * 104 | * @param BlobProperties $properties value. 105 | * 106 | * @return void 107 | */ 108 | protected function setProperties(BlobProperties $properties) 109 | { 110 | $this->properties = $properties; 111 | } 112 | 113 | /** 114 | * Gets blob contentStream. 115 | * 116 | * @return resource 117 | */ 118 | public function getContentStream() 119 | { 120 | return $this->contentStream; 121 | } 122 | 123 | /** 124 | * Sets blob contentStream. 125 | * 126 | * @param resource $contentStream The stream handle. 127 | * 128 | * @return void 129 | */ 130 | protected function setContentStream($contentStream) 131 | { 132 | $this->contentStream = $contentStream; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/Blob/Models/GetContainerACLResult.php: -------------------------------------------------------------------------------- 1 | 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 | * Holds container ACL 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 GetContainerACLResult 38 | { 39 | private $containerACL; 40 | private $lastModified; 41 | 42 | private $etag; 43 | 44 | /** 45 | * Parses the given array into signed identifiers 46 | * 47 | * @param string $publicAccess container public access 48 | * @param string $etag container etag 49 | * @param \DateTime $lastModified last modification date 50 | * @param array $parsed parsed response into array 51 | * representation 52 | * 53 | * @internal 54 | * 55 | * @return self 56 | */ 57 | public static function create( 58 | $publicAccess, 59 | $etag, 60 | \DateTime $lastModified, 61 | array $parsed = null 62 | ) { 63 | $result = new GetContainerAclResult(); 64 | $result->setETag($etag); 65 | $result->setLastModified($lastModified); 66 | $acl = ContainerACL::create($publicAccess, $parsed); 67 | $result->setContainerAcl($acl); 68 | 69 | return $result; 70 | } 71 | 72 | /** 73 | * Gets container ACL 74 | * 75 | * @return ContainerACL 76 | */ 77 | public function getContainerAcl() 78 | { 79 | return $this->containerACL; 80 | } 81 | 82 | /** 83 | * Sets container ACL 84 | * 85 | * @param ContainerACL $containerACL value. 86 | * 87 | * @return void 88 | */ 89 | protected function setContainerAcl(ContainerACL $containerACL) 90 | { 91 | $this->containerACL = $containerACL; 92 | } 93 | 94 | /** 95 | * Gets container lastModified. 96 | * 97 | * @return \DateTime. 98 | */ 99 | public function getLastModified() 100 | { 101 | return $this->lastModified; 102 | } 103 | 104 | /** 105 | * Sets container lastModified. 106 | * 107 | * @param \DateTime $lastModified value. 108 | * 109 | * @return void 110 | */ 111 | protected function setLastModified(\DateTime $lastModified) 112 | { 113 | $this->lastModified = $lastModified; 114 | } 115 | 116 | /** 117 | * Gets container etag. 118 | * 119 | * @return string 120 | */ 121 | public function getETag() 122 | { 123 | return $this->etag; 124 | } 125 | 126 | /** 127 | * Sets container etag. 128 | * 129 | * @param string $etag value. 130 | * 131 | * @return void 132 | */ 133 | protected function setETag($etag) 134 | { 135 | $this->etag = $etag; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/Blob/Models/GetContainerPropertiesResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\MetadataTrait; 28 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 29 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 30 | use MicrosoftAzure\Storage\Common\Internal\Validate; 31 | 32 | /** 33 | * Holds result of getContainerProperties and getContainerMetadata 34 | * 35 | * @category Microsoft 36 | * @package MicrosoftAzure\Storage\Blob\Models 37 | * @author Azure Storage PHP SDK 38 | * @copyright 2016 Microsoft Corporation 39 | * @license https://github.com/azure/azure-storage-php/LICENSE 40 | * @link https://github.com/azure/azure-storage-php 41 | */ 42 | class GetContainerPropertiesResult 43 | { 44 | use MetadataTrait; 45 | 46 | private $leaseStatus; 47 | private $leaseState; 48 | private $leaseDuration; 49 | private $publicAccess; 50 | 51 | /** 52 | * Gets blob leaseStatus. 53 | * 54 | * @return string 55 | */ 56 | public function getLeaseStatus() 57 | { 58 | return $this->leaseStatus; 59 | } 60 | 61 | /** 62 | * Sets blob leaseStatus. 63 | * 64 | * @param string $leaseStatus value. 65 | * 66 | * @return void 67 | */ 68 | public function setLeaseStatus($leaseStatus) 69 | { 70 | $this->leaseStatus = $leaseStatus; 71 | } 72 | 73 | /** 74 | * Gets blob lease state. 75 | * 76 | * @return string 77 | */ 78 | public function getLeaseState() 79 | { 80 | return $this->leaseState; 81 | } 82 | 83 | /** 84 | * Sets blob lease state. 85 | * 86 | * @param string $leaseState value. 87 | * 88 | * @return void 89 | */ 90 | public function setLeaseState($leaseState) 91 | { 92 | $this->leaseState = $leaseState; 93 | } 94 | 95 | /** 96 | * Gets blob lease duration. 97 | * 98 | * @return string 99 | */ 100 | public function getLeaseDuration() 101 | { 102 | return $this->leaseDuration; 103 | } 104 | 105 | /** 106 | * Sets blob leaseStatus. 107 | * 108 | * @param string $leaseDuration value. 109 | * 110 | * @return void 111 | */ 112 | public function setLeaseDuration($leaseDuration) 113 | { 114 | $this->leaseDuration = $leaseDuration; 115 | } 116 | 117 | /** 118 | * Gets container publicAccess. 119 | * 120 | * @return string 121 | */ 122 | public function getPublicAccess() 123 | { 124 | return $this->publicAccess; 125 | } 126 | 127 | /** 128 | * Sets container publicAccess. 129 | * 130 | * @param string $publicAccess value. 131 | * 132 | * @return void 133 | */ 134 | public function setPublicAccess($publicAccess) 135 | { 136 | Validate::isTrue( 137 | PublicAccessType::isValid($publicAccess), 138 | Resources::INVALID_BLOB_PAT_MSG 139 | ); 140 | $this->publicAccess = $publicAccess; 141 | } 142 | 143 | /** 144 | * Create an instance using the response headers from the API call. 145 | * 146 | * @param array $responseHeaders The array contains all the response headers 147 | * 148 | * @internal 149 | * 150 | * @return GetContainerPropertiesResult 151 | */ 152 | public static function create(array $responseHeaders) 153 | { 154 | $result = static::createMetadataResult($responseHeaders); 155 | 156 | $result->setLeaseStatus(Utilities::tryGetValueInsensitive( 157 | Resources::X_MS_LEASE_STATUS, 158 | $responseHeaders 159 | )); 160 | $result->setLeaseState(Utilities::tryGetValueInsensitive( 161 | Resources::X_MS_LEASE_STATE, 162 | $responseHeaders 163 | )); 164 | $result->setLeaseDuration(Utilities::tryGetValueInsensitive( 165 | Resources::X_MS_LEASE_DURATION, 166 | $responseHeaders 167 | )); 168 | $result->setPublicAccess(Utilities::tryGetValueInsensitive( 169 | Resources::X_MS_BLOB_PUBLIC_ACCESS, 170 | $responseHeaders 171 | )); 172 | 173 | return $result; 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /src/Blob/Models/LeaseMode.php: -------------------------------------------------------------------------------- 1 | 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 | * Modes for leasing a blob 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 LeaseMode 38 | { 39 | const ACQUIRE_ACTION = 'acquire'; 40 | const RENEW_ACTION = 'renew'; 41 | const RELEASE_ACTION = 'release'; 42 | const BREAK_ACTION = 'break'; 43 | const CHANGE_ACTION = 'change'; 44 | } 45 | -------------------------------------------------------------------------------- /src/Blob/Models/LeaseResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | 30 | /** 31 | * The result of calling acquireLease API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class LeaseResult 41 | { 42 | private $leaseId; 43 | 44 | /** 45 | * Creates LeaseResult from response headers 46 | * 47 | * @param array $headers response headers 48 | * 49 | * @internal 50 | * 51 | * @return \MicrosoftAzure\Storage\Blob\Models\LeaseResult 52 | */ 53 | public static function create(array $headers) 54 | { 55 | $result = new LeaseResult(); 56 | 57 | $result->setLeaseId( 58 | Utilities::tryGetValue($headers, Resources::X_MS_LEASE_ID) 59 | ); 60 | 61 | return $result; 62 | } 63 | 64 | /** 65 | * Gets lease Id for the blob 66 | * 67 | * @return string 68 | */ 69 | public function getLeaseId() 70 | { 71 | return $this->leaseId; 72 | } 73 | 74 | /** 75 | * Sets lease Id for the blob 76 | * 77 | * @param string $leaseId the blob lease id. 78 | * 79 | * @return void 80 | */ 81 | protected function setLeaseId($leaseId) 82 | { 83 | $this->leaseId = $leaseId; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Blob/Models/ListBlobBlocksOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | 29 | /** 30 | * Optional parameters for listBlobBlock wrapper 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class ListBlobBlocksOptions extends BlobServiceOptions 40 | { 41 | private $_snapshot; 42 | private $_includeUncommittedBlobs; 43 | private $_includeCommittedBlobs; 44 | private static $_listType; 45 | 46 | /** 47 | * Constructs the static variable $listType. 48 | */ 49 | public function __construct() 50 | { 51 | parent::__construct(); 52 | self::$_listType[true][true] = 'all'; 53 | self::$_listType[true][false] = 'uncommitted'; 54 | self::$_listType[false][true] = 'committed'; 55 | self::$_listType[false][false] = 'all'; 56 | 57 | $this->_includeUncommittedBlobs = false; 58 | $this->_includeCommittedBlobs = false; 59 | } 60 | 61 | /** 62 | * Gets blob snapshot. 63 | * 64 | * @return string 65 | */ 66 | public function getSnapshot() 67 | { 68 | return $this->_snapshot; 69 | } 70 | 71 | /** 72 | * Sets blob snapshot. 73 | * 74 | * @param string $snapshot value. 75 | * 76 | * @return void 77 | */ 78 | public function setSnapshot($snapshot) 79 | { 80 | $this->_snapshot = $snapshot; 81 | } 82 | 83 | /** 84 | * Sets the include uncommittedBlobs flag. 85 | * 86 | * @param bool $includeUncommittedBlobs value. 87 | * 88 | * @return void 89 | */ 90 | public function setIncludeUncommittedBlobs($includeUncommittedBlobs) 91 | { 92 | Validate::isBoolean($includeUncommittedBlobs); 93 | $this->_includeUncommittedBlobs = $includeUncommittedBlobs; 94 | } 95 | 96 | /** 97 | * Indicates if uncommittedBlobs is included or not. 98 | * 99 | * @return boolean 100 | */ 101 | public function getIncludeUncommittedBlobs() 102 | { 103 | return $this->_includeUncommittedBlobs; 104 | } 105 | 106 | /** 107 | * Sets the include committedBlobs flag. 108 | * 109 | * @param bool $includeCommittedBlobs value. 110 | * 111 | * @return void 112 | */ 113 | public function setIncludeCommittedBlobs($includeCommittedBlobs) 114 | { 115 | Validate::isBoolean($includeCommittedBlobs); 116 | $this->_includeCommittedBlobs = $includeCommittedBlobs; 117 | } 118 | 119 | /** 120 | * Indicates if committedBlobs is included or not. 121 | * 122 | * @return boolean 123 | */ 124 | public function getIncludeCommittedBlobs() 125 | { 126 | return $this->_includeCommittedBlobs; 127 | } 128 | 129 | /** 130 | * Gets block list type. 131 | * 132 | * @return string 133 | */ 134 | public function getBlockListType() 135 | { 136 | $includeUncommitted = $this->_includeUncommittedBlobs; 137 | $includeCommitted = $this->_includeCommittedBlobs; 138 | 139 | return self::$_listType[$includeUncommitted][$includeCommitted]; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/Blob/Models/ListBlobBlocksResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 29 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 30 | 31 | /** 32 | * Holds result of listBlobBlocks 33 | * 34 | * @category Microsoft 35 | * @package MicrosoftAzure\Storage\Blob\Models 36 | * @author Azure Storage PHP SDK 37 | * @copyright 2016 Microsoft Corporation 38 | * @license https://github.com/azure/azure-storage-php/LICENSE 39 | * @link https://github.com/azure/azure-storage-php 40 | */ 41 | class ListBlobBlocksResult 42 | { 43 | private $lastModified; 44 | private $etag; 45 | private $contentType; 46 | private $contentLength; 47 | private $committedBlocks; 48 | private $uncommittedBlocks; 49 | 50 | /** 51 | * Gets block entries from parsed response 52 | * 53 | * @param array $parsed HTTP response 54 | * @param string $type Block type 55 | * 56 | * @return array 57 | */ 58 | private static function getEntries(array $parsed, $type) 59 | { 60 | $entries = array(); 61 | 62 | if (is_array($parsed)) { 63 | $rawEntries = array(); 64 | 65 | if (array_key_exists($type, $parsed) 66 | && is_array($parsed[$type]) 67 | && !empty($parsed[$type]) 68 | ) { 69 | $rawEntries = Utilities::getArray($parsed[$type]['Block']); 70 | } 71 | 72 | foreach ($rawEntries as $value) { 73 | $entries[$value['Name']] = $value['Size']; 74 | } 75 | } 76 | 77 | return $entries; 78 | } 79 | 80 | /** 81 | * Creates ListBlobBlocksResult from given response headers and parsed body 82 | * 83 | * @param array $headers HTTP response headers 84 | * @param array $parsed HTTP response body in array representation 85 | * 86 | * @internal 87 | * 88 | * @return ListBlobBlocksResult 89 | */ 90 | public static function create(array $headers, array $parsed) 91 | { 92 | $result = new ListBlobBlocksResult(); 93 | $clean = array_change_key_case($headers); 94 | 95 | $result->setETag(Utilities::tryGetValue($clean, Resources::ETAG)); 96 | $date = Utilities::tryGetValue($clean, Resources::LAST_MODIFIED); 97 | if (!is_null($date)) { 98 | $date = Utilities::rfc1123ToDateTime($date); 99 | $result->setLastModified($date); 100 | } 101 | $result->setContentLength( 102 | intval( 103 | Utilities::tryGetValue($clean, Resources::X_MS_BLOB_CONTENT_LENGTH) 104 | ) 105 | ); 106 | $result->setContentType( 107 | Utilities::tryGetValue($clean, Resources::CONTENT_TYPE_LOWER_CASE) 108 | ); 109 | 110 | $result->uncommittedBlocks = self::getEntries( 111 | $parsed, 112 | 'UncommittedBlocks' 113 | ); 114 | $result->committedBlocks = self::getEntries($parsed, 'CommittedBlocks'); 115 | 116 | return $result; 117 | } 118 | 119 | /** 120 | * Gets blob lastModified. 121 | * 122 | * @return \DateTime 123 | */ 124 | public function getLastModified() 125 | { 126 | return $this->lastModified; 127 | } 128 | 129 | /** 130 | * Sets blob lastModified. 131 | * 132 | * @param \DateTime $lastModified value. 133 | * 134 | * @return void 135 | */ 136 | protected function setLastModified(\DateTime $lastModified) 137 | { 138 | Validate::isDate($lastModified); 139 | $this->lastModified = $lastModified; 140 | } 141 | 142 | /** 143 | * Gets blob etag. 144 | * 145 | * @return string 146 | */ 147 | public function getETag() 148 | { 149 | return $this->etag; 150 | } 151 | 152 | /** 153 | * Sets blob etag. 154 | * 155 | * @param string $etag value. 156 | * 157 | * @return void 158 | */ 159 | protected function setETag($etag) 160 | { 161 | $this->etag = $etag; 162 | } 163 | 164 | /** 165 | * Gets blob contentType. 166 | * 167 | * @return string 168 | */ 169 | public function getContentType() 170 | { 171 | return $this->contentType; 172 | } 173 | 174 | /** 175 | * Sets blob contentType. 176 | * 177 | * @param string $contentType value. 178 | * 179 | * @return void 180 | */ 181 | protected function setContentType($contentType) 182 | { 183 | $this->contentType = $contentType; 184 | } 185 | 186 | /** 187 | * Gets blob contentLength. 188 | * 189 | * @return integer 190 | */ 191 | public function getContentLength() 192 | { 193 | return $this->contentLength; 194 | } 195 | 196 | /** 197 | * Sets blob contentLength. 198 | * 199 | * @param integer $contentLength value. 200 | * 201 | * @return void 202 | */ 203 | protected function setContentLength($contentLength) 204 | { 205 | Validate::isInteger($contentLength, 'contentLength'); 206 | $this->contentLength = $contentLength; 207 | } 208 | 209 | /** 210 | * Gets uncommitted blocks 211 | * 212 | * @return array 213 | */ 214 | public function getUncommittedBlocks() 215 | { 216 | return $this->uncommittedBlocks; 217 | } 218 | 219 | /** 220 | * Sets uncommitted blocks 221 | * 222 | * @param array $uncommittedBlocks The uncommitted blocks entries 223 | * 224 | * @return void 225 | */ 226 | protected function setUncommittedBlocks(array $uncommittedBlocks) 227 | { 228 | $this->uncommittedBlocks = $uncommittedBlocks; 229 | } 230 | 231 | /** 232 | * Gets committed blocks 233 | * 234 | * @return array 235 | */ 236 | public function getCommittedBlocks() 237 | { 238 | return $this->committedBlocks; 239 | } 240 | 241 | /** 242 | * Sets committed blocks 243 | * 244 | * @param array $committedBlocks The committed blocks entries 245 | * 246 | * @return void 247 | */ 248 | protected function setCommittedBlocks(array $committedBlocks) 249 | { 250 | $this->committedBlocks = $committedBlocks; 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /src/Blob/Models/ListBlobsOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; 29 | 30 | /** 31 | * Optional parameters for listBlobs API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class ListBlobsOptions extends BlobServiceOptions 41 | { 42 | use MarkerContinuationTokenTrait; 43 | 44 | private $_prefix; 45 | private $_delimiter; 46 | private $_maxResults; 47 | private $_includeMetadata; 48 | private $_includeSnapshots; 49 | private $_includeUncommittedBlobs; 50 | private $_includeCopy; 51 | private $_includeDeleted; 52 | 53 | /** 54 | * Gets prefix. 55 | * 56 | * @return string 57 | */ 58 | public function getPrefix() 59 | { 60 | return $this->_prefix; 61 | } 62 | 63 | /** 64 | * Sets prefix. 65 | * 66 | * @param string $prefix value. 67 | * 68 | * @return void 69 | */ 70 | public function setPrefix($prefix) 71 | { 72 | Validate::canCastAsString($prefix, 'prefix'); 73 | $this->_prefix = $prefix; 74 | } 75 | 76 | /** 77 | * Gets delimiter. 78 | * 79 | * @return string 80 | */ 81 | public function getDelimiter() 82 | { 83 | return $this->_delimiter; 84 | } 85 | 86 | /** 87 | * Sets prefix. 88 | * 89 | * @param string $delimiter value. 90 | * 91 | * @return void 92 | */ 93 | public function setDelimiter($delimiter) 94 | { 95 | Validate::canCastAsString($delimiter, 'delimiter'); 96 | $this->_delimiter = $delimiter; 97 | } 98 | 99 | /** 100 | * Gets max results. 101 | * 102 | * @return integer 103 | */ 104 | public function getMaxResults() 105 | { 106 | return $this->_maxResults; 107 | } 108 | 109 | /** 110 | * Sets max results. 111 | * 112 | * @param integer $maxResults value. 113 | * 114 | * @return void 115 | */ 116 | public function setMaxResults($maxResults) 117 | { 118 | Validate::isInteger($maxResults, 'maxResults'); 119 | $this->_maxResults = $maxResults; 120 | } 121 | 122 | /** 123 | * Indicates if metadata is included or not. 124 | * 125 | * @return boolean 126 | */ 127 | public function getIncludeMetadata() 128 | { 129 | return $this->_includeMetadata; 130 | } 131 | 132 | /** 133 | * Sets the include metadata flag. 134 | * 135 | * @param bool $includeMetadata value. 136 | * 137 | * @return void 138 | */ 139 | public function setIncludeMetadata($includeMetadata) 140 | { 141 | Validate::isBoolean($includeMetadata); 142 | $this->_includeMetadata = $includeMetadata; 143 | } 144 | 145 | /** 146 | * Indicates if snapshots is included or not. 147 | * 148 | * @return boolean 149 | */ 150 | public function getIncludeSnapshots() 151 | { 152 | return $this->_includeSnapshots; 153 | } 154 | 155 | /** 156 | * Sets the include snapshots flag. 157 | * 158 | * @param bool $includeSnapshots value. 159 | * 160 | * @return void 161 | */ 162 | public function setIncludeSnapshots($includeSnapshots) 163 | { 164 | Validate::isBoolean($includeSnapshots); 165 | $this->_includeSnapshots = $includeSnapshots; 166 | } 167 | 168 | /** 169 | * Indicates if uncommittedBlobs is included or not. 170 | * 171 | * @return boolean 172 | */ 173 | public function getIncludeUncommittedBlobs() 174 | { 175 | return $this->_includeUncommittedBlobs; 176 | } 177 | 178 | /** 179 | * Sets the include uncommittedBlobs flag. 180 | * 181 | * @param bool $includeUncommittedBlobs value. 182 | * 183 | * @return void 184 | */ 185 | public function setIncludeUncommittedBlobs($includeUncommittedBlobs) 186 | { 187 | Validate::isBoolean($includeUncommittedBlobs); 188 | $this->_includeUncommittedBlobs = $includeUncommittedBlobs; 189 | } 190 | 191 | /** 192 | * Indicates if copy is included or not. 193 | * 194 | * @return boolean 195 | */ 196 | public function getIncludeCopy() 197 | { 198 | return $this->_includeCopy; 199 | } 200 | 201 | /** 202 | * Sets the include copy flag. 203 | * 204 | * @param bool $includeCopy value. 205 | * 206 | * @return void 207 | */ 208 | public function setIncludeCopy($includeCopy) 209 | { 210 | Validate::isBoolean($includeCopy); 211 | $this->_includeCopy = $includeCopy; 212 | } 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 | } 236 | } 237 | -------------------------------------------------------------------------------- /src/Blob/Models/ListContainersOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; 28 | use MicrosoftAzure\Storage\Common\Internal\Validate; 29 | 30 | /** 31 | * Options for listBlobs API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class ListContainersOptions extends BlobServiceOptions 41 | { 42 | use MarkerContinuationTokenTrait; 43 | 44 | private $_prefix; 45 | private $_maxResults; 46 | private $_includeMetadata; 47 | 48 | /** 49 | * Gets prefix - filters the results to return only containers whose name 50 | * begins with the specified prefix. 51 | * 52 | * @return string 53 | */ 54 | public function getPrefix() 55 | { 56 | return $this->_prefix; 57 | } 58 | 59 | /** 60 | * Sets prefix - filters the results to return only containers whose name 61 | * begins with the specified prefix. 62 | * 63 | * @param string $prefix value. 64 | * 65 | * @return void 66 | */ 67 | public function setPrefix($prefix) 68 | { 69 | Validate::canCastAsString($prefix, 'prefix'); 70 | $this->_prefix = $prefix; 71 | } 72 | 73 | /** 74 | * Gets max results which specifies the maximum number of containers to return. 75 | * If the request does not specify maxresults, or specifies a value 76 | * greater than 5,000, the server will return up to 5,000 items. 77 | * If the parameter is set to a value less than or equal to zero, 78 | * the server will return status code 400 (Bad Request). 79 | * 80 | * @return string 81 | */ 82 | public function getMaxResults() 83 | { 84 | return $this->_maxResults; 85 | } 86 | 87 | /** 88 | * Sets max results which specifies the maximum number of containers to return. 89 | * If the request does not specify maxresults, or specifies a value 90 | * greater than 5,000, the server will return up to 5,000 items. 91 | * If the parameter is set to a value less than or equal to zero, 92 | * the server will return status code 400 (Bad Request). 93 | * 94 | * @param string $maxResults value. 95 | * 96 | * @return void 97 | */ 98 | public function setMaxResults($maxResults) 99 | { 100 | Validate::canCastAsString($maxResults, 'maxResults'); 101 | $this->_maxResults = $maxResults; 102 | } 103 | 104 | /** 105 | * Indicates if metadata is included or not. 106 | * 107 | * @return string 108 | */ 109 | public function getIncludeMetadata() 110 | { 111 | return $this->_includeMetadata; 112 | } 113 | 114 | /** 115 | * Sets the include metadata flag. 116 | * 117 | * @param bool $includeMetadata value. 118 | * 119 | * @return void 120 | */ 121 | public function setIncludeMetadata($includeMetadata) 122 | { 123 | Validate::isBoolean($includeMetadata); 124 | $this->_includeMetadata = $includeMetadata; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/Blob/Models/ListPageBlobRangesDiffResult.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2017 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 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 28 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 29 | use MicrosoftAzure\Storage\Common\Models\RangeDiff; 30 | 31 | /** 32 | * Holds result of calling listPageBlobRangesDiff wrapper 33 | * 34 | * @category Microsoft 35 | * @package MicrosoftAzure\Storage\Blob\Models 36 | * @author Azure Storage PHP SDK 37 | * @copyright 2017 Microsoft Corporation 38 | * @license https://github.com/azure/azure-storage-php/LICENSE 39 | * @link https://github.com/azure/azure-storage-php 40 | */ 41 | class ListPageBlobRangesDiffResult extends ListPageBlobRangesResult 42 | { 43 | /** 44 | * Creates ListPageBlobRangesDiffResult object from $parsed response in array representation 45 | * 46 | * @param array $headers HTTP response headers 47 | * @param array $parsed parsed response in array format. 48 | * 49 | * @internal 50 | * 51 | * @return ListPageBlobRangesDiffResult 52 | */ 53 | public static function create(array $headers, array $parsed = null) 54 | { 55 | $result = new ListPageBlobRangesDiffResult(); 56 | $headers = array_change_key_case($headers); 57 | 58 | $date = $headers[Resources::LAST_MODIFIED]; 59 | $date = Utilities::rfc1123ToDateTime($date); 60 | $blobLength = intval($headers[Resources::X_MS_BLOB_CONTENT_LENGTH]); 61 | 62 | $result->setContentLength($blobLength); 63 | $result->setLastModified($date); 64 | $result->setETag($headers[Resources::ETAG]); 65 | 66 | if (is_null($parsed)) { 67 | return $result; 68 | } 69 | 70 | $parsed = array_change_key_case($parsed); 71 | 72 | $rawRanges = array(); 73 | if (!empty($parsed[strtolower(Resources::XTAG_PAGE_RANGE)])) { 74 | $rawRanges = Utilities::getArray($parsed[strtolower(Resources::XTAG_PAGE_RANGE)]); 75 | } 76 | 77 | $pageRanges = array(); 78 | foreach ($rawRanges as $value) { 79 | $pageRanges[] = new RangeDiff( 80 | intval($value[Resources::XTAG_RANGE_START]), 81 | intval($value[Resources::XTAG_RANGE_END]) 82 | ); 83 | } 84 | 85 | $rawRanges = array(); 86 | if (!empty($parsed[strtolower(Resources::XTAG_CLEAR_RANGE)])) { 87 | $rawRanges = Utilities::getArray($parsed[strtolower(Resources::XTAG_CLEAR_RANGE)]); 88 | } 89 | 90 | foreach ($rawRanges as $value) { 91 | $pageRanges[] = new RangeDiff( 92 | intval($value[Resources::XTAG_RANGE_START]), 93 | intval($value[Resources::XTAG_RANGE_END]), 94 | true 95 | ); 96 | } 97 | 98 | $result->setRanges($pageRanges); 99 | return $result; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/Blob/Models/ListPageBlobRangesOptions.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | use MicrosoftAzure\Storage\Common\Models\Range; 29 | 30 | /** 31 | * Optional parameters for listPageBlobRanges wrapper 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class ListPageBlobRangesOptions extends BlobServiceOptions 41 | { 42 | private $snapshot; 43 | private $range; 44 | private $_rangeStart; 45 | private $_rangeEnd; 46 | 47 | /** 48 | * Gets blob snapshot. 49 | * 50 | * @return string 51 | */ 52 | public function getSnapshot() 53 | { 54 | return $this->snapshot; 55 | } 56 | 57 | /** 58 | * Sets blob snapshot. 59 | * 60 | * @param string $snapshot value. 61 | * 62 | * @return void 63 | */ 64 | public function setSnapshot($snapshot) 65 | { 66 | $this->snapshot = $snapshot; 67 | } 68 | 69 | /** 70 | * Gets Blob range. 71 | * 72 | * @return Range 73 | */ 74 | public function getRange() 75 | { 76 | return $this->range; 77 | } 78 | 79 | /** 80 | * Sets Blob range. 81 | * 82 | * @param Range $range value. 83 | * 84 | * @return void 85 | */ 86 | public function setRange(Range $range) 87 | { 88 | $this->range = $range; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Blob/Models/ListPageBlobRangesResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Common\Internal\Validate; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 30 | use MicrosoftAzure\Storage\Common\Models\Range; 31 | 32 | /** 33 | * Holds result of calling listPageBlobRanges wrapper 34 | * 35 | * @category Microsoft 36 | * @package MicrosoftAzure\Storage\Blob\Models 37 | * @author Azure Storage PHP SDK 38 | * @copyright 2016 Microsoft Corporation 39 | * @license https://github.com/azure/azure-storage-php/LICENSE 40 | * @link https://github.com/azure/azure-storage-php 41 | */ 42 | class ListPageBlobRangesResult 43 | { 44 | private $_lastModified; 45 | private $_etag; 46 | private $_contentLength; 47 | private $_pageRanges; 48 | 49 | /** 50 | * Creates BlobProperties object from $parsed response in array representation 51 | * 52 | * @param array $headers HTTP response headers 53 | * @param array $parsed parsed response in array format. 54 | * 55 | * @internal 56 | * 57 | * @return ListPageBlobRangesResult 58 | */ 59 | public static function create(array $headers, array $parsed = null) 60 | { 61 | $result = new ListPageBlobRangesResult(); 62 | $headers = array_change_key_case($headers); 63 | 64 | $date = $headers[Resources::LAST_MODIFIED]; 65 | $date = Utilities::rfc1123ToDateTime($date); 66 | $blobLength = intval($headers[Resources::X_MS_BLOB_CONTENT_LENGTH]); 67 | $rawRanges = array(); 68 | 69 | if (!empty($parsed[Resources::XTAG_PAGE_RANGE])) { 70 | $parsed = array_change_key_case($parsed); 71 | $rawRanges = Utilities::getArray($parsed[strtolower(RESOURCES::XTAG_PAGE_RANGE)]); 72 | } 73 | 74 | $pageRanges = array(); 75 | foreach ($rawRanges as $value) { 76 | $pageRanges[] = new Range( 77 | intval($value[Resources::XTAG_RANGE_START]), 78 | intval($value[Resources::XTAG_RANGE_END]) 79 | ); 80 | } 81 | $result->setRanges($pageRanges); 82 | $result->setContentLength($blobLength); 83 | $result->setETag($headers[Resources::ETAG]); 84 | $result->setLastModified($date); 85 | 86 | return $result; 87 | } 88 | 89 | /** 90 | * Gets blob lastModified. 91 | * 92 | * @return \DateTime 93 | */ 94 | public function getLastModified() 95 | { 96 | return $this->_lastModified; 97 | } 98 | 99 | /** 100 | * Sets blob lastModified. 101 | * 102 | * @param \DateTime $lastModified value. 103 | * 104 | * @return void 105 | */ 106 | protected function setLastModified(\DateTime $lastModified) 107 | { 108 | Validate::isDate($lastModified); 109 | $this->_lastModified = $lastModified; 110 | } 111 | 112 | /** 113 | * Gets blob etag. 114 | * 115 | * @return string 116 | */ 117 | public function getETag() 118 | { 119 | return $this->_etag; 120 | } 121 | 122 | /** 123 | * Sets blob etag. 124 | * 125 | * @param string $etag value. 126 | * 127 | * @return void 128 | */ 129 | protected function setETag($etag) 130 | { 131 | Validate::canCastAsString($etag, 'etag'); 132 | $this->_etag = $etag; 133 | } 134 | 135 | /** 136 | * Gets blob contentLength. 137 | * 138 | * @return integer 139 | */ 140 | public function getContentLength() 141 | { 142 | return $this->_contentLength; 143 | } 144 | 145 | /** 146 | * Sets blob contentLength. 147 | * 148 | * @param integer $contentLength value. 149 | * 150 | * @return void 151 | */ 152 | protected function setContentLength($contentLength) 153 | { 154 | Validate::isInteger($contentLength, 'contentLength'); 155 | $this->_contentLength = $contentLength; 156 | } 157 | 158 | /** 159 | * Gets page ranges 160 | * 161 | * @return array 162 | */ 163 | public function getRanges() 164 | { 165 | return $this->_pageRanges; 166 | } 167 | 168 | /** 169 | * Sets page ranges 170 | * 171 | * @param array $pageRanges page ranges to set 172 | * 173 | * @return void 174 | */ 175 | protected function setRanges(array $pageRanges) 176 | { 177 | $this->_pageRanges = array(); 178 | foreach ($pageRanges as $pageRange) { 179 | $this->_pageRanges[] = clone $pageRange; 180 | } 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /src/Blob/Models/PageWriteOption.php: -------------------------------------------------------------------------------- 1 | 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 | * Holds available blob page write options 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 PageWriteOption 38 | { 39 | const CLEAR_OPTION = 'clear'; 40 | const UPDATE_OPTION = 'update'; 41 | } 42 | -------------------------------------------------------------------------------- /src/Blob/Models/PublicAccessType.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | 29 | /** 30 | * Holds public access types for a container. 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2016 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class PublicAccessType 40 | { 41 | const NONE = null; 42 | const BLOBS_ONLY = 'blob'; 43 | const CONTAINER_AND_BLOBS = 'container'; 44 | 45 | /** 46 | * Validates the public access. 47 | * 48 | * @param string $type The public access type. 49 | * 50 | * @internal 51 | * 52 | * @return boolean 53 | */ 54 | public static function isValid($type) 55 | { 56 | // When $type is null, switch statement will take it 57 | // equal to self::NONE (EMPTY_STRING) 58 | switch ($type) { 59 | case self::NONE: 60 | case self::BLOBS_ONLY: 61 | case self::CONTAINER_AND_BLOBS: 62 | return true; 63 | default: 64 | return false; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Blob/Models/PutBlobResult.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2017 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | 30 | /** 31 | * The result of calling PutBlob API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2017 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class PutBlobResult 41 | { 42 | private $contentMD5; 43 | private $etag; 44 | private $lastModified; 45 | private $requestServerEncrypted; 46 | 47 | /** 48 | * Creates PutBlobResult object from the response of the put blob request. 49 | * 50 | * @param array $headers The HTTP response headers in array representation. 51 | * 52 | * @internal 53 | * 54 | * @return PutBlobResult 55 | */ 56 | public static function create(array $headers) 57 | { 58 | $result = new PutBlobResult(); 59 | 60 | $result->setETag( 61 | Utilities::tryGetValueInsensitive( 62 | Resources::ETAG, 63 | $headers 64 | ) 65 | ); 66 | 67 | if (Utilities::arrayKeyExistsInsensitive( 68 | Resources::LAST_MODIFIED, 69 | $headers 70 | )) { 71 | $lastModified = Utilities::tryGetValueInsensitive( 72 | Resources::LAST_MODIFIED, 73 | $headers 74 | ); 75 | $result->setLastModified(Utilities::rfc1123ToDateTime($lastModified)); 76 | } 77 | 78 | $result->setContentMD5( 79 | Utilities::tryGetValueInsensitive(Resources::CONTENT_MD5, $headers) 80 | ); 81 | 82 | $result->setRequestServerEncrypted( 83 | Utilities::toBoolean( 84 | Utilities::tryGetValueInsensitive( 85 | Resources::X_MS_REQUEST_SERVER_ENCRYPTED, 86 | $headers 87 | ), 88 | true 89 | ) 90 | ); 91 | 92 | return $result; 93 | } 94 | 95 | /** 96 | * Gets ETag. 97 | * 98 | * @return string 99 | */ 100 | public function getETag() 101 | { 102 | return $this->etag; 103 | } 104 | 105 | /** 106 | * Sets ETag. 107 | * 108 | * @param string $etag value. 109 | * 110 | * @return void 111 | */ 112 | protected function setETag($etag) 113 | { 114 | $this->etag = $etag; 115 | } 116 | 117 | /** 118 | * Gets blob lastModified. 119 | * 120 | * @return \DateTime 121 | */ 122 | public function getLastModified() 123 | { 124 | return $this->lastModified; 125 | } 126 | 127 | /** 128 | * Sets blob lastModified. 129 | * 130 | * @param \DateTime $lastModified value. 131 | * 132 | * @return void 133 | */ 134 | protected function setLastModified(\DateTime $lastModified) 135 | { 136 | $this->lastModified = $lastModified; 137 | } 138 | 139 | /** 140 | * Gets block content MD5. 141 | * 142 | * @return string 143 | */ 144 | public function getContentMD5() 145 | { 146 | return $this->contentMD5; 147 | } 148 | 149 | /** 150 | * Sets the content MD5 value. 151 | * 152 | * @param string $contentMD5 conent MD5 as a string. 153 | * 154 | * @return void 155 | */ 156 | protected function setContentMD5($contentMD5) 157 | { 158 | $this->contentMD5 = $contentMD5; 159 | } 160 | 161 | /** 162 | * Gets the whether the contents of the request are successfully encrypted. 163 | * 164 | * @return boolean 165 | */ 166 | public function getRequestServerEncrypted() 167 | { 168 | return $this->requestServerEncrypted; 169 | } 170 | 171 | /** 172 | * Sets the request server encryption value. 173 | * 174 | * @param boolean $requestServerEncrypted 175 | * 176 | * @return void 177 | */ 178 | public function setRequestServerEncrypted($requestServerEncrypted) 179 | { 180 | $this->requestServerEncrypted = $requestServerEncrypted; 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /src/Blob/Models/PutBlockResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 29 | 30 | /** 31 | * The result of calling PutBlock API. 32 | * 33 | * @category Microsoft 34 | * @package MicrosoftAzure\Storage\Blob\Models 35 | * @author Azure Storage PHP SDK 36 | * @copyright 2016 Microsoft Corporation 37 | * @license https://github.com/azure/azure-storage-php/LICENSE 38 | * @link https://github.com/azure/azure-storage-php 39 | */ 40 | class PutBlockResult 41 | { 42 | private $contentMD5; 43 | private $requestServerEncrypted; 44 | 45 | /** 46 | * Creates PutBlockResult object from the response of the put block request. 47 | * 48 | * @param array $headers The HTTP response headers in array representation. 49 | * 50 | * @internal 51 | * 52 | * @return PutBlockResult 53 | */ 54 | public static function create(array $headers) 55 | { 56 | $result = new PutBlockResult(); 57 | 58 | $result->setContentMD5( 59 | Utilities::tryGetValueInsensitive(Resources::CONTENT_MD5, $headers) 60 | ); 61 | 62 | $result->setRequestServerEncrypted( 63 | Utilities::toBoolean( 64 | Utilities::tryGetValueInsensitive( 65 | Resources::X_MS_REQUEST_SERVER_ENCRYPTED, 66 | $headers 67 | ), 68 | true 69 | ) 70 | ); 71 | 72 | return $result; 73 | } 74 | 75 | /** 76 | * Gets block content MD5. 77 | * 78 | * @return string 79 | */ 80 | public function getContentMD5() 81 | { 82 | return $this->contentMD5; 83 | } 84 | 85 | /** 86 | * Sets the content MD5 value. 87 | * 88 | * @param string $contentMD5 conent MD5 as a string. 89 | * 90 | * @return void 91 | */ 92 | protected function setContentMD5($contentMD5) 93 | { 94 | $this->contentMD5 = $contentMD5; 95 | } 96 | 97 | /** 98 | * Gets the whether the contents of the request are successfully encrypted. 99 | * 100 | * @return boolean 101 | */ 102 | public function getRequestServerEncrypted() 103 | { 104 | return $this->requestServerEncrypted; 105 | } 106 | 107 | /** 108 | * Sets the request server encryption value. 109 | * 110 | * @param boolean $requestServerEncrypted 111 | * 112 | * @return void 113 | */ 114 | public function setRequestServerEncrypted($requestServerEncrypted) 115 | { 116 | $this->requestServerEncrypted = $requestServerEncrypted; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/Blob/Models/SetBlobMetadataResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Validate; 29 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 30 | 31 | /** 32 | * Holds results of calling getBlobMetadata wrapper 33 | * 34 | * @category Microsoft 35 | * @package MicrosoftAzure\Storage\Blob\Models 36 | * @author Azure Storage PHP SDK 37 | * @copyright 2016 Microsoft Corporation 38 | * @license https://github.com/azure/azure-storage-php/LICENSE 39 | * @link https://github.com/azure/azure-storage-php 40 | */ 41 | class SetBlobMetadataResult 42 | { 43 | private $etag; 44 | private $lastModified; 45 | private $requestServerEncrypted; 46 | 47 | /** 48 | * Creates SetBlobMetadataResult from response headers. 49 | * 50 | * @param array $headers response headers 51 | * 52 | * @internal 53 | * 54 | * @return SetBlobMetadataResult 55 | */ 56 | public static function create(array $headers) 57 | { 58 | $result = new SetBlobMetadataResult(); 59 | 60 | $result->setETag(Utilities::tryGetValueInsensitive( 61 | Resources::ETAG, 62 | $headers 63 | )); 64 | 65 | $date = Utilities::tryGetValueInsensitive( 66 | Resources::LAST_MODIFIED, 67 | $headers 68 | ); 69 | $result->setLastModified(Utilities::rfc1123ToDateTime($date)); 70 | 71 | $result->setRequestServerEncrypted( 72 | Utilities::toBoolean( 73 | Utilities::tryGetValueInsensitive( 74 | Resources::X_MS_REQUEST_SERVER_ENCRYPTED, 75 | $headers 76 | ), 77 | true 78 | ) 79 | ); 80 | 81 | return $result; 82 | } 83 | 84 | /** 85 | * Gets blob lastModified. 86 | * 87 | * @return \DateTime 88 | */ 89 | public function getLastModified() 90 | { 91 | return $this->lastModified; 92 | } 93 | 94 | /** 95 | * Sets blob lastModified. 96 | * 97 | * @param \DateTime $lastModified value. 98 | * 99 | * @return void 100 | */ 101 | protected function setLastModified(\DateTime $lastModified) 102 | { 103 | Validate::isDate($lastModified); 104 | $this->lastModified = $lastModified; 105 | } 106 | 107 | /** 108 | * Gets blob etag. 109 | * 110 | * @return string 111 | */ 112 | public function getETag() 113 | { 114 | return $this->etag; 115 | } 116 | 117 | /** 118 | * Sets blob etag. 119 | * 120 | * @param string $etag value. 121 | * 122 | * @return void 123 | */ 124 | protected function setETag($etag) 125 | { 126 | Validate::canCastAsString($etag, 'etag'); 127 | $this->etag = $etag; 128 | } 129 | 130 | /** 131 | * Gets the whether the contents of the request are successfully encrypted. 132 | * 133 | * @return boolean 134 | */ 135 | public function getRequestServerEncrypted() 136 | { 137 | return $this->requestServerEncrypted; 138 | } 139 | 140 | /** 141 | * Sets the request server encryption value. 142 | * 143 | * @param boolean $requestServerEncrypted 144 | * 145 | * @return void 146 | */ 147 | public function setRequestServerEncrypted($requestServerEncrypted) 148 | { 149 | $this->requestServerEncrypted = $requestServerEncrypted; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/Blob/Models/SetBlobPropertiesOptions.php: -------------------------------------------------------------------------------- 1 | 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 setBlobProperties wrapper 29 | * 30 | * @category Microsoft 31 | * @package MicrosoftAzure\Storage\Blob\Models 32 | * @author Azure Storage PHP SDK 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 SetBlobPropertiesOptions extends BlobServiceOptions 38 | { 39 | private $_blobProperties; 40 | private $_sequenceNumberAction; 41 | 42 | /** 43 | * Creates a new SetBlobPropertiesOptions with a specified BlobProperties 44 | * instance. 45 | * 46 | * @param BlobProperties $blobProperties The blob properties instance. 47 | */ 48 | public function __construct(BlobProperties $blobProperties = null) 49 | { 50 | parent::__construct(); 51 | $this->_blobProperties = is_null($blobProperties) 52 | ? new BlobProperties() : clone $blobProperties; 53 | } 54 | 55 | /** 56 | * Gets blob sequenceNumber. 57 | * 58 | * @return integer 59 | */ 60 | public function getSequenceNumber() 61 | { 62 | return $this->_blobProperties->getSequenceNumber(); 63 | } 64 | 65 | /** 66 | * Sets blob sequenceNumber. 67 | * 68 | * @param integer $sequenceNumber value. 69 | * 70 | * @return void 71 | */ 72 | public function setSequenceNumber($sequenceNumber) 73 | { 74 | $this->_blobProperties->setSequenceNumber($sequenceNumber); 75 | } 76 | 77 | /** 78 | * Gets lease Id for the blob 79 | * 80 | * @return string 81 | */ 82 | public function getSequenceNumberAction() 83 | { 84 | return $this->_sequenceNumberAction; 85 | } 86 | 87 | /** 88 | * Sets lease Id for the blob 89 | * 90 | * @param string $sequenceNumberAction action. 91 | * 92 | * @return void 93 | */ 94 | public function setSequenceNumberAction($sequenceNumberAction) 95 | { 96 | $this->_sequenceNumberAction = $sequenceNumberAction; 97 | } 98 | 99 | /** 100 | * Gets blob contentLength. 101 | * 102 | * @return integer 103 | */ 104 | public function getContentLength() 105 | { 106 | return $this->_blobProperties->getContentLength(); 107 | } 108 | 109 | /** 110 | * Sets blob contentLength. 111 | * 112 | * @param integer $contentLength value. 113 | * 114 | * @return void 115 | */ 116 | public function setContentLength($contentLength) 117 | { 118 | $this->_blobProperties->setContentLength($contentLength); 119 | } 120 | 121 | /** 122 | * Gets ContentType. 123 | * 124 | * @return string 125 | */ 126 | public function getContentType() 127 | { 128 | return $this->_blobProperties->getContentType(); 129 | } 130 | 131 | /** 132 | * Sets ContentType. 133 | * 134 | * @param string $contentType value. 135 | * 136 | * @return void 137 | */ 138 | public function setContentType($contentType) 139 | { 140 | $this->_blobProperties->setContentType($contentType); 141 | } 142 | 143 | /** 144 | * Gets ContentEncoding. 145 | * 146 | * @return string 147 | */ 148 | public function getContentEncoding() 149 | { 150 | return $this->_blobProperties->getContentEncoding(); 151 | } 152 | 153 | /** 154 | * Sets ContentEncoding. 155 | * 156 | * @param string $contentEncoding value. 157 | * 158 | * @return void 159 | */ 160 | public function setContentEncoding($contentEncoding) 161 | { 162 | $this->_blobProperties->setContentEncoding($contentEncoding); 163 | } 164 | 165 | /** 166 | * Gets ContentLanguage. 167 | * 168 | * @return string 169 | */ 170 | public function getContentLanguage() 171 | { 172 | return $this->_blobProperties->getContentLanguage(); 173 | } 174 | 175 | /** 176 | * Sets ContentLanguage. 177 | * 178 | * @param string $contentLanguage value. 179 | * 180 | * @return void 181 | */ 182 | public function setContentLanguage($contentLanguage) 183 | { 184 | $this->_blobProperties->setContentLanguage($contentLanguage); 185 | } 186 | 187 | /** 188 | * Gets ContentMD5. 189 | * 190 | * @return void 191 | */ 192 | public function getContentMD5() 193 | { 194 | return $this->_blobProperties->getContentMD5(); 195 | } 196 | 197 | /** 198 | * Sets blob ContentMD5. 199 | * 200 | * @param string $contentMD5 value. 201 | * 202 | * @return void 203 | */ 204 | public function setContentMD5($contentMD5) 205 | { 206 | $this->_blobProperties->setContentMD5($contentMD5); 207 | } 208 | 209 | /** 210 | * Gets cache control. 211 | * 212 | * @return string 213 | */ 214 | public function getCacheControl() 215 | { 216 | return $this->_blobProperties->getCacheControl(); 217 | } 218 | 219 | /** 220 | * Sets cacheControl. 221 | * 222 | * @param string $cacheControl value to use. 223 | * 224 | * @return void 225 | */ 226 | public function setCacheControl($cacheControl) 227 | { 228 | $this->_blobProperties->setCacheControl($cacheControl); 229 | } 230 | 231 | /** 232 | * Gets content disposition. 233 | * 234 | * @return string 235 | */ 236 | public function getContentDisposition() 237 | { 238 | return $this->_blobProperties->getContentDisposition(); 239 | } 240 | 241 | /** 242 | * Sets contentDisposition. 243 | * 244 | * @param string $contentDisposition value to use. 245 | * 246 | * @return void 247 | */ 248 | public function setContentDisposition($contentDisposition) 249 | { 250 | $this->_blobProperties->setContentDisposition($contentDisposition); 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /src/Blob/Models/SetBlobPropertiesResult.php: -------------------------------------------------------------------------------- 1 | 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 | use MicrosoftAzure\Storage\Blob\Internal\BlobResources as Resources; 28 | use MicrosoftAzure\Storage\Common\Internal\Validate; 29 | use MicrosoftAzure\Storage\Common\Internal\Utilities; 30 | 31 | /** 32 | * Holds result of calling setBlobProperties wrapper 33 | * 34 | * @category Microsoft 35 | * @package MicrosoftAzure\Storage\Blob\Models 36 | * @author Azure Storage PHP SDK 37 | * @copyright 2016 Microsoft Corporation 38 | * @license https://github.com/azure/azure-storage-php/LICENSE 39 | * @link https://github.com/azure/azure-storage-php 40 | */ 41 | class SetBlobPropertiesResult 42 | { 43 | private $_lastModified; 44 | private $_etag; 45 | private $_sequenceNumber; 46 | 47 | /** 48 | * Creates SetBlobPropertiesResult from response headers. 49 | * 50 | * @param array $headers response headers 51 | * 52 | * @internal 53 | * 54 | * @return SetBlobPropertiesResult 55 | */ 56 | public static function create(array $headers) 57 | { 58 | $result = new SetBlobPropertiesResult(); 59 | $date = Utilities::tryGetValueInsensitive( 60 | Resources::LAST_MODIFIED, 61 | $headers 62 | ); 63 | $result->setLastModified(Utilities::rfc1123ToDateTime($date)); 64 | $result->setETag(Utilities::tryGetValueInsensitive( 65 | Resources::ETAG, 66 | $headers 67 | )); 68 | $result->setSequenceNumber(Utilities::tryGetValueInsensitive( 69 | Resources::X_MS_BLOB_SEQUENCE_NUMBER, 70 | $headers 71 | )); 72 | 73 | return $result; 74 | } 75 | 76 | /** 77 | * Gets blob lastModified. 78 | * 79 | * @return \DateTime 80 | */ 81 | public function getLastModified() 82 | { 83 | return $this->_lastModified; 84 | } 85 | 86 | /** 87 | * Sets blob lastModified. 88 | * 89 | * @param \DateTime $lastModified value. 90 | * 91 | * @return void 92 | */ 93 | protected function setLastModified(\DateTime $lastModified) 94 | { 95 | Validate::isDate($lastModified); 96 | $this->_lastModified = $lastModified; 97 | } 98 | 99 | /** 100 | * Gets blob etag. 101 | * 102 | * @return string 103 | */ 104 | public function getETag() 105 | { 106 | return $this->_etag; 107 | } 108 | 109 | /** 110 | * Sets blob etag. 111 | * 112 | * @param string $etag value. 113 | * 114 | * @return void 115 | */ 116 | protected function setETag($etag) 117 | { 118 | Validate::canCastAsString($etag, 'etag'); 119 | $this->_etag = $etag; 120 | } 121 | 122 | /** 123 | * Gets blob sequenceNumber. 124 | * 125 | * @return int 126 | */ 127 | public function getSequenceNumber() 128 | { 129 | return $this->_sequenceNumber; 130 | } 131 | 132 | /** 133 | * Sets blob sequenceNumber. 134 | * 135 | * @param int $sequenceNumber value. 136 | * 137 | * @return void 138 | */ 139 | protected function setSequenceNumber($sequenceNumber) 140 | { 141 | Validate::isInteger($sequenceNumber, 'sequenceNumber'); 142 | $this->_sequenceNumber = $sequenceNumber; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/Blob/Models/SetBlobTierOptions.php: -------------------------------------------------------------------------------- 1 | 20 | * @copyright 2018 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 | use MicrosoftAzure\Storage\Common\Models\ServiceOptions; 28 | 29 | /** 30 | * Optional parameters for SetBlobTier. 31 | * 32 | * @category Microsoft 33 | * @package MicrosoftAzure\Storage\Blob\Models 34 | * @author Azure Storage PHP SDK 35 | * @copyright 2018 Microsoft Corporation 36 | * @license https://github.com/azure/azure-storage-php/LICENSE 37 | * @link https://github.com/azure/azure-storage-php 38 | */ 39 | class SetBlobTierOptions extends ServiceOptions 40 | { 41 | use AccessTierTrait; 42 | } 43 | -------------------------------------------------------------------------------- /src/Blob/Models/UndeleteBlobOptions.php: -------------------------------------------------------------------------------- 1 | 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 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 | } 40 | --------------------------------------------------------------------------------