PageRenderTime 86ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/plugins/backwpup/sdk/WindowsAzure/Blob/BlobRestProxy.php

https://bitbucket.org/cesarmedrano/cesarmedrano
PHP | 1494 lines | 1043 code | 129 blank | 322 comment | 29 complexity | c940b1c4e402f5d9f41c54835a9d7113 MD5 | raw file
  1. <?php
  2. /**
  3. * LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. *
  14. * PHP version 5
  15. *
  16. * @category Microsoft
  17. * @package WindowsAzure\Blob
  18. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  19. * @copyright 2012 Microsoft Corporation
  20. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  21. * @link https://github.com/windowsazure/azure-sdk-for-php
  22. */
  23. namespace WindowsAzure\Blob;
  24. use WindowsAzure\Common\Internal\Utilities;
  25. use WindowsAzure\Common\Internal\Resources;
  26. use WindowsAzure\Common\Internal\Validate;
  27. use WindowsAzure\Common\Models\ServiceProperties;
  28. use WindowsAzure\Common\Internal\ServiceRestProxy;
  29. use WindowsAzure\Blob\Internal\IBlob;
  30. use WindowsAzure\Blob\Models\BlobServiceOptions;
  31. use WindowsAzure\Common\Models\GetServicePropertiesResult;
  32. use WindowsAzure\Blob\Models\ListContainersOptions;
  33. use WindowsAzure\Blob\Models\ListContainersResult;
  34. use WindowsAzure\Blob\Models\CreateContainerOptions;
  35. use WindowsAzure\Blob\Models\GetContainerPropertiesResult;
  36. use WindowsAzure\Blob\Models\GetContainerAclResult;
  37. use WindowsAzure\Blob\Models\SetContainerMetadataOptions;
  38. use WindowsAzure\Blob\Models\DeleteContainerOptions;
  39. use WindowsAzure\Blob\Models\ListBlobsOptions;
  40. use WindowsAzure\Blob\Models\ListBlobsResult;
  41. use WindowsAzure\Blob\Models\BlobType;
  42. use WindowsAzure\Blob\Models\CreateBlobOptions;
  43. use WindowsAzure\Blob\Models\BlobProperties;
  44. use WindowsAzure\Blob\Models\GetBlobPropertiesOptions;
  45. use WindowsAzure\Blob\Models\GetBlobPropertiesResult;
  46. use WindowsAzure\Blob\Models\SetBlobPropertiesOptions;
  47. use WindowsAzure\Blob\Models\SetBlobPropertiesResult;
  48. use WindowsAzure\Blob\Models\GetBlobMetadataOptions;
  49. use WindowsAzure\Blob\Models\GetBlobMetadataResult;
  50. use WindowsAzure\Blob\Models\SetBlobMetadataOptions;
  51. use WindowsAzure\Blob\Models\SetBlobMetadataResult;
  52. use WindowsAzure\Blob\Models\GetBlobOptions;
  53. use WindowsAzure\Blob\Models\GetBlobResult;
  54. use WindowsAzure\Blob\Models\DeleteBlobOptions;
  55. use WindowsAzure\Blob\Models\LeaseMode;
  56. use WindowsAzure\Blob\Models\AcquireLeaseOptions;
  57. use WindowsAzure\Blob\Models\AcquireLeaseResult;
  58. use WindowsAzure\Blob\Models\CreateBlobPagesOptions;
  59. use WindowsAzure\Blob\Models\CreateBlobPagesResult;
  60. use WindowsAzure\Blob\Models\PageWriteOption;
  61. use WindowsAzure\Blob\Models\ListPageBlobRangesOptions;
  62. use WindowsAzure\Blob\Models\ListPageBlobRangesResult;
  63. use WindowsAzure\Blob\Models\CreateBlobBlockOptions;
  64. use WindowsAzure\Blob\Models\CommitBlobBlocksOptions;
  65. use WindowsAzure\Blob\Models\BlockList;
  66. use WindowsAzure\Blob\Models\ListBlobBlocksOptions;
  67. use WindowsAzure\Blob\Models\ListBlobBlocksResult;
  68. use WindowsAzure\Blob\Models\CopyBlobOptions;
  69. use WindowsAzure\Blob\Models\CreateBlobSnapshotOptions;
  70. use WindowsAzure\Blob\Models\CreateBlobSnapshotResult;
  71. use WindowsAzure\Blob\Models\PageRange;
  72. use WindowsAzure\Blob\Models\CopyBlobResult;
  73. /**
  74. * This class constructs HTTP requests and receive HTTP responses for blob
  75. * service layer.
  76. *
  77. * @category Microsoft
  78. * @package WindowsAzure\Blob
  79. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  80. * @copyright 2012 Microsoft Corporation
  81. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  82. * @version Release: @package_version@
  83. * @link https://github.com/windowsazure/azure-sdk-for-php
  84. */
  85. class BlobRestProxy extends ServiceRestProxy implements IBlob
  86. {
  87. /**
  88. * Gets the copy blob source name with specified parameters.
  89. *
  90. * @param string $containerName The name of the container.
  91. * @param string $blobName The name of the blob.
  92. * @param Models\CopyBlobOptions $options The optional parameters.
  93. *
  94. * @return string
  95. */
  96. private function _getCopyBlobSourceName($containerName, $blobName, $options)
  97. {
  98. $sourceName = '/' . $this->getAccountName();
  99. $sourceName .= '/' . $this->_createPath($containerName, $blobName);
  100. if (!is_null($options->getSourceSnapshot())) {
  101. $sourceName .= '?snapshot=' . $options->getSourceSnapshot();
  102. }
  103. return $sourceName;
  104. }
  105. /**
  106. * Creates URI path for blob.
  107. *
  108. * @param string $container The container name.
  109. * @param string $blob The blob name.
  110. *
  111. * @return string
  112. */
  113. private function _createPath($container, $blob)
  114. {
  115. // Empty container means accessing default container
  116. if (empty($container)) {
  117. return $blob;
  118. } else {
  119. return $container . '/' . $blob;
  120. }
  121. }
  122. /**
  123. * Creates GetBlobPropertiesResult from headers array.
  124. *
  125. * @param array $headers The HTTP response headers array.
  126. *
  127. * @return GetBlobPropertiesResult
  128. */
  129. private function _getBlobPropertiesResultFromResponse($headers)
  130. {
  131. $result = new GetBlobPropertiesResult();
  132. $properties = new BlobProperties();
  133. $d = $headers[Resources::LAST_MODIFIED];
  134. $bType = $headers[Resources::X_MS_BLOB_TYPE];
  135. $cLength = intval($headers[Resources::CONTENT_LENGTH]);
  136. $lStatus = Utilities::tryGetValue($headers, Resources::X_MS_LEASE_STATUS);
  137. $cType = Utilities::tryGetValue($headers, Resources::CONTENT_TYPE);
  138. $cMD5 = Utilities::tryGetValue($headers, Resources::CONTENT_MD5);
  139. $cEncoding = Utilities::tryGetValue($headers, Resources::CONTENT_ENCODING);
  140. $cLanguage = Utilities::tryGetValue($headers, Resources::CONTENT_LANGUAGE);
  141. $cControl = Utilities::tryGetValue($headers, Resources::CACHE_CONTROL);
  142. $etag = $headers[Resources::ETAG];
  143. $metadata = $this->getMetadataArray($headers);
  144. if (array_key_exists(Resources::X_MS_BLOB_SEQUENCE_NUMBER, $headers)) {
  145. $sNumber = intval($headers[Resources::X_MS_BLOB_SEQUENCE_NUMBER]);
  146. $properties->setSequenceNumber($sNumber);
  147. }
  148. $properties->setBlobType($bType);
  149. $properties->setCacheControl($cControl);
  150. $properties->setContentEncoding($cEncoding);
  151. $properties->setContentLanguage($cLanguage);
  152. $properties->setContentLength($cLength);
  153. $properties->setContentMD5($cMD5);
  154. $properties->setContentType($cType);
  155. $properties->setETag($etag);
  156. $properties->setLastModified(Utilities::rfc1123ToDateTime($d));
  157. $properties->setLeaseStatus($lStatus);
  158. $result->setProperties($properties);
  159. $result->setMetadata($metadata);
  160. return $result;
  161. }
  162. /**
  163. * Helper method for getContainerProperties and getContainerMetadata.
  164. *
  165. * @param string $container The container name.
  166. * @param Models\BlobServiceOptions $options The optional parameters.
  167. * @param string $operation The operation string. Should be
  168. * 'metadata' to get metadata.
  169. *
  170. * @return Models\GetContainerPropertiesResult
  171. */
  172. private function _getContainerPropertiesImpl($container, $options = null,
  173. $operation = null
  174. ) {
  175. Validate::isString($container, 'container');
  176. $method = Resources::HTTP_GET;
  177. $headers = array();
  178. $queryParams = array();
  179. $postParams = array();
  180. $path = $container;
  181. $statusCode = Resources::STATUS_OK;
  182. if (is_null($options)) {
  183. $options = new BlobServiceOptions();
  184. }
  185. $this->addOptionalQueryParam(
  186. $queryParams,
  187. Resources::QP_REST_TYPE,
  188. 'container'
  189. );
  190. $this->addOptionalQueryParam(
  191. $queryParams,
  192. Resources::QP_COMP,
  193. $operation
  194. );
  195. $this->addOptionalQueryParam(
  196. $queryParams,
  197. Resources::QP_TIMEOUT,
  198. $options->getTimeout()
  199. );
  200. $response = $this->send(
  201. $method,
  202. $headers,
  203. $queryParams,
  204. $postParams,
  205. $path,
  206. $statusCode
  207. );
  208. $result = new GetContainerPropertiesResult();
  209. $metadata = $this->getMetadataArray($response->getHeader());
  210. $date = $response->getHeader(Resources::LAST_MODIFIED);
  211. $date = Utilities::rfc1123ToDateTime($date);
  212. $result->setETag($response->getHeader(Resources::ETAG));
  213. $result->setMetadata($metadata);
  214. $result->setLastModified($date);
  215. return $result;
  216. }
  217. /**
  218. * Adds optional create blob headers.
  219. *
  220. * @param CreateBlobOptions $options The optional parameters.
  221. * @param array $headers The HTTP request headers.
  222. *
  223. * @return array
  224. */
  225. private function _addCreateBlobOptionalHeaders($options, $headers)
  226. {
  227. $contentType = $options->getContentType();
  228. $metadata = $options->getMetadata();
  229. $blobContentType = $options->getBlobContentType();
  230. $blobContentEncoding = $options->getBlobContentEncoding();
  231. $blobContentLanguage = $options->getBlobContentLanguage();
  232. $blobContentMD5 = $options->getBlobContentMD5();
  233. $blobCacheControl = $options->getBlobCacheControl();
  234. $leaseId = $options->getLeaseId();
  235. if (!is_null($contentType)) {
  236. $this->addOptionalHeader(
  237. $headers,
  238. Resources::CONTENT_TYPE,
  239. $options->getContentType()
  240. );
  241. } else {
  242. $this->addOptionalHeader(
  243. $headers,
  244. Resources::CONTENT_TYPE,
  245. Resources::BINARY_FILE_TYPE
  246. );
  247. }
  248. $headers = $this->addMetadataHeaders($headers, $metadata);
  249. $headers = $this->addOptionalAccessConditionHeader(
  250. $headers, $options->getAccessCondition()
  251. );
  252. $this->addOptionalHeader(
  253. $headers,
  254. Resources::CONTENT_ENCODING,
  255. $options->getContentEncoding()
  256. );
  257. $this->addOptionalHeader(
  258. $headers,
  259. Resources::CONTENT_LANGUAGE,
  260. $options->getContentLanguage()
  261. );
  262. $this->addOptionalHeader(
  263. $headers,
  264. Resources::CONTENT_MD5,
  265. $options->getContentMD5()
  266. );
  267. $this->addOptionalHeader(
  268. $headers,
  269. Resources::CACHE_CONTROL,
  270. $options->getCacheControl()
  271. );
  272. $this->addOptionalHeader(
  273. $headers,
  274. Resources::X_MS_LEASE_ID,
  275. $leaseId
  276. );
  277. $this->addOptionalHeader(
  278. $headers,
  279. Resources::X_MS_BLOB_CONTENT_TYPE,
  280. $blobContentType
  281. );
  282. $this->addOptionalHeader(
  283. $headers,
  284. Resources::X_MS_BLOB_CONTENT_ENCODING,
  285. $blobContentEncoding
  286. );
  287. $this->addOptionalHeader(
  288. $headers,
  289. Resources::X_MS_BLOB_CONTENT_LANGUAGE,
  290. $blobContentLanguage
  291. );
  292. $this->addOptionalHeader(
  293. $headers,
  294. Resources::X_MS_BLOB_CONTENT_MD5,
  295. $blobContentMD5
  296. );
  297. $this->addOptionalHeader(
  298. $headers,
  299. Resources::X_MS_BLOB_CACHE_CONTROL,
  300. $blobCacheControl
  301. );
  302. return $headers;
  303. }
  304. /**
  305. * Adds Range header to the headers array.
  306. *
  307. * @param array $headers The HTTP request headers.
  308. * @param integer $start The start byte.
  309. * @param integer $end The end byte.
  310. *
  311. * @return array
  312. */
  313. private function _addOptionalRangeHeader($headers, $start, $end)
  314. {
  315. if (!is_null($start) || !is_null($end)) {
  316. $range = $start . '-' . $end;
  317. $rangeValue = 'bytes=' . $range;
  318. $this->addOptionalHeader($headers, Resources::RANGE, $rangeValue);
  319. }
  320. return $headers;
  321. }
  322. /**
  323. * Does the actual work for leasing a blob.
  324. *
  325. * @param string $leaseAction The lease action string.
  326. * @param string $container The container name.
  327. * @param string $blob The blob to lease name.
  328. * @param string $leaseId The existing lease id.
  329. * @param BlobServiceOptions $options The optional parameters.
  330. * @param AccessCondition $accessCondition The access conditions.
  331. *
  332. * @return AcquireLeaseResult
  333. */
  334. private function _putLeaseImpl($leaseAction, $container, $blob, $leaseId,
  335. $options, $accessCondition = null
  336. ) {
  337. Validate::isString($blob, 'blob');
  338. Validate::notNullOrEmpty($blob, 'blob');
  339. Validate::isString($container, 'container');
  340. $method = Resources::HTTP_PUT;
  341. $headers = array();
  342. $queryParams = array();
  343. $postParams = array();
  344. $path = $this->_createPath($container, $blob);
  345. $statusCode = Resources::EMPTY_STRING;
  346. switch ($leaseAction) {
  347. case LeaseMode::ACQUIRE_ACTION:
  348. $statusCode = Resources::STATUS_CREATED;
  349. break;
  350. case LeaseMode::RENEW_ACTION:
  351. $statusCode = Resources::STATUS_OK;
  352. break;
  353. case LeaseMode::RELEASE_ACTION:
  354. $statusCode = Resources::STATUS_OK;
  355. break;
  356. case LeaseMode::BREAK_ACTION:
  357. $statusCode = Resources::STATUS_ACCEPTED;
  358. break;
  359. default:
  360. throw new \Exception(Resources::NOT_IMPLEMENTED_MSG);
  361. }
  362. if (!is_null($options)) {
  363. $options = new BlobServiceOptions();
  364. }
  365. $headers = $this->addOptionalAccessConditionHeader(
  366. $headers, $accessCondition
  367. );
  368. $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $leaseId);
  369. $this->addOptionalHeader(
  370. $headers,
  371. Resources::X_MS_LEASE_ACTION,
  372. $leaseAction
  373. );
  374. $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'lease');
  375. $this->addOptionalQueryParam(
  376. $queryParams,
  377. Resources::QP_TIMEOUT,
  378. $options->getTimeout()
  379. );
  380. $response = $this->send(
  381. $method,
  382. $headers,
  383. $queryParams,
  384. $postParams,
  385. $path,
  386. $statusCode
  387. );
  388. return AcquireLeaseResult::create($response->getHeader());
  389. }
  390. /**
  391. * Does actual work for create and clear blob pages.
  392. *
  393. * @param string $action Either clear or create.
  394. * @param string $container The container name.
  395. * @param string $blob The blob name.
  396. * @param PageRange $range The page ranges.
  397. * @param string|resource $content The content stream.
  398. * @param CreateBlobPagesOptions $options The optional parameters.
  399. *
  400. * @return CreateBlobPagesResult
  401. */
  402. private function _updatePageBlobPagesImpl($action, $container, $blob, $range,
  403. $content, $options = null
  404. ) {
  405. Validate::isString($blob, 'blob');
  406. Validate::notNullOrEmpty($blob, 'blob');
  407. Validate::isString($container, 'container');
  408. Validate::isTrue(
  409. $range instanceof PageRange,
  410. sprintf(
  411. Resources::INVALID_PARAM_MSG,
  412. 'range',
  413. get_class(new PageRange())
  414. )
  415. );
  416. Validate::isTrue(
  417. is_string($content) || is_resource($content),
  418. sprintf(Resources::INVALID_PARAM_MSG, 'content', 'string|resource')
  419. );
  420. $method = Resources::HTTP_PUT;
  421. $headers = array();
  422. $queryParams = array();
  423. $postParams = array();
  424. $path = $this->_createPath($container, $blob);
  425. $statusCode = Resources::STATUS_CREATED;
  426. // If read file failed for any reason it will throw an exception.
  427. $body = is_resource($content) ? stream_get_contents($content) : $content;
  428. if (is_null($options)) {
  429. $options = new CreateBlobPagesOptions();
  430. }
  431. $headers = $this->_addOptionalRangeHeader(
  432. $headers, $range->getStart(), $range->getEnd()
  433. );
  434. $headers = $this->addOptionalAccessConditionHeader(
  435. $headers, $options->getAccessCondition()
  436. );
  437. $this->addOptionalHeader(
  438. $headers,
  439. Resources::X_MS_LEASE_ID,
  440. $options->getLeaseId()
  441. );
  442. $this->addOptionalHeader(
  443. $headers,
  444. Resources::CONTENT_MD5,
  445. $options->getContentMD5()
  446. );
  447. $this->addOptionalHeader(
  448. $headers,
  449. Resources::X_MS_PAGE_WRITE,
  450. $action
  451. );
  452. $this->addOptionalHeader(
  453. $headers,
  454. Resources::CONTENT_TYPE,
  455. Resources::URL_ENCODED_CONTENT_TYPE
  456. );
  457. $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'page');
  458. $this->addOptionalQueryParam(
  459. $queryParams,
  460. Resources::QP_TIMEOUT,
  461. $options->getTimeout()
  462. );
  463. $response = $this->send(
  464. $method,
  465. $headers,
  466. $queryParams,
  467. $postParams,
  468. $path,
  469. $statusCode,
  470. $body
  471. );
  472. return CreateBlobPagesResult::create($response->getHeader());
  473. }
  474. /**
  475. * Gets the properties of the Blob service.
  476. *
  477. * @param Models\BlobServiceOptions $options The optional parameters.
  478. *
  479. * @return WindowsAzure\Common\Models\GetServicePropertiesResult
  480. *
  481. * @see http://msdn.microsoft.com/en-us/library/windowsazure/hh452239.aspx
  482. */
  483. public function getServiceProperties($options = null)
  484. {
  485. $method = Resources::HTTP_GET;
  486. $headers = array();
  487. $queryParams = array();
  488. $postParams = array();
  489. $path = Resources::EMPTY_STRING;
  490. $statusCode = Resources::STATUS_OK;
  491. if (is_null($options)) {
  492. $options = new BlobServiceOptions();
  493. }
  494. $this->addOptionalQueryParam(
  495. $queryParams,
  496. Resources::QP_TIMEOUT,
  497. $options->getTimeout()
  498. );
  499. $this->addOptionalQueryParam(
  500. $queryParams,
  501. Resources::QP_REST_TYPE,
  502. 'service'
  503. );
  504. $this->addOptionalQueryParam(
  505. $queryParams,
  506. Resources::QP_COMP,
  507. 'properties'
  508. );
  509. $response = $this->send(
  510. $method,
  511. $headers,
  512. $queryParams,
  513. $postParams,
  514. $path,
  515. $statusCode
  516. );
  517. $parsed = $this->dataSerializer->unserialize($response->getBody());
  518. return GetServicePropertiesResult::create($parsed);
  519. }
  520. /**
  521. * Sets the properties of the Blob service.
  522. *
  523. * It's recommended to use getServiceProperties, alter the returned object and
  524. * then use setServiceProperties with this altered object.
  525. *
  526. * @param ServiceProperties $serviceProperties The service properties.
  527. * @param Models\BlobServiceOptions $options The optional parameters.
  528. *
  529. * @return none
  530. *
  531. * @see http://msdn.microsoft.com/en-us/library/windowsazure/hh452235.aspx
  532. */
  533. public function setServiceProperties($serviceProperties, $options = null)
  534. {
  535. Validate::isTrue(
  536. $serviceProperties instanceof ServiceProperties,
  537. Resources::INVALID_SVC_PROP_MSG
  538. );
  539. $method = Resources::HTTP_PUT;
  540. $headers = array();
  541. $queryParams = array();
  542. $postParams = array();
  543. $statusCode = Resources::STATUS_ACCEPTED;
  544. $path = Resources::EMPTY_STRING;
  545. $body = $serviceProperties->toXml($this->dataSerializer);
  546. if (is_null($options)) {
  547. $options = new BlobServiceOptions();
  548. }
  549. $this->addOptionalQueryParam(
  550. $queryParams,
  551. Resources::QP_REST_TYPE,
  552. 'service'
  553. );
  554. $this->addOptionalQueryParam(
  555. $queryParams,
  556. Resources::QP_COMP,
  557. 'properties'
  558. );
  559. $this->addOptionalQueryParam(
  560. $queryParams,
  561. Resources::QP_TIMEOUT,
  562. $options->getTimeout()
  563. );
  564. $this->addOptionalHeader(
  565. $headers,
  566. Resources::CONTENT_TYPE,
  567. Resources::URL_ENCODED_CONTENT_TYPE
  568. );
  569. $this->send(
  570. $method,
  571. $headers,
  572. $queryParams,
  573. $postParams,
  574. $path,
  575. $statusCode,
  576. $body
  577. );
  578. }
  579. /**
  580. * Lists all of the containers in the given storage account.
  581. *
  582. * @param Models\ListContainersOptions $options The optional parameters.
  583. *
  584. * @return WindowsAzure\Blob\Models\ListContainersResult
  585. *
  586. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179352.aspx
  587. */
  588. public function listContainers($options = null)
  589. {
  590. $method = Resources::HTTP_GET;
  591. $headers = array();
  592. $queryParams = array();
  593. $postParams = array();
  594. $path = Resources::EMPTY_STRING;
  595. $statusCode = Resources::STATUS_OK;
  596. if (is_null($options)) {
  597. $options = new ListContainersOptions();
  598. }
  599. $this->addOptionalQueryParam(
  600. $queryParams,
  601. Resources::QP_TIMEOUT,
  602. $options->getTimeout()
  603. );
  604. $this->addOptionalQueryParam(
  605. $queryParams,
  606. Resources::QP_COMP,
  607. 'list'
  608. );
  609. $this->addOptionalQueryParam(
  610. $queryParams,
  611. Resources::QP_PREFIX,
  612. $options->getPrefix()
  613. );
  614. $this->addOptionalQueryParam(
  615. $queryParams,
  616. Resources::QP_MARKER,
  617. $options->getMarker()
  618. );
  619. $this->addOptionalQueryParam(
  620. $queryParams,
  621. Resources::QP_MAX_RESULTS,
  622. $options->getMaxResults()
  623. );
  624. $isInclude = $options->getIncludeMetadata();
  625. $isInclude = $isInclude ? 'metadata' : null;
  626. $this->addOptionalQueryParam(
  627. $queryParams,
  628. Resources::QP_INCLUDE,
  629. $isInclude
  630. );
  631. $response = $this->send(
  632. $method,
  633. $headers,
  634. $queryParams,
  635. $postParams,
  636. $path,
  637. $statusCode
  638. );
  639. $parsed = $this->dataSerializer->unserialize($response->getBody());
  640. return ListContainersResult::create($parsed);
  641. }
  642. /**
  643. * Creates a new container in the given storage account.
  644. *
  645. * @param string $container The container name.
  646. * @param Models\CreateContainerOptions $options The optional parameters.
  647. *
  648. * @return none
  649. *
  650. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179468.aspx
  651. */
  652. public function createContainer($container, $options = null)
  653. {
  654. Validate::isString($container, 'container');
  655. Validate::notNullOrEmpty($container, 'container');
  656. $method = Resources::HTTP_PUT;
  657. $headers = array();
  658. $postParams = array();
  659. $queryParams = array(Resources::QP_REST_TYPE => 'container');
  660. $path = $container;
  661. $statusCode = Resources::STATUS_CREATED;
  662. if (is_null($options)) {
  663. $options = new CreateContainerOptions();
  664. }
  665. $this->addOptionalQueryParam(
  666. $queryParams,
  667. Resources::QP_TIMEOUT,
  668. $options->getTimeout()
  669. );
  670. $metadata = $options->getMetadata();
  671. $headers = $this->generateMetadataHeaders($metadata);
  672. $this->addOptionalHeader(
  673. $headers,
  674. Resources::X_MS_BLOB_PUBLIC_ACCESS,
  675. $options->getPublicAccess()
  676. );
  677. $this->send(
  678. $method,
  679. $headers,
  680. $queryParams,
  681. $postParams,
  682. $path,
  683. $statusCode
  684. );
  685. }
  686. /**
  687. * Creates a new container in the given storage account.
  688. *
  689. * @param string $container The container name.
  690. * @param Models\DeleteContainerOptions $options The optional parameters.
  691. *
  692. * @return none
  693. *
  694. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179408.aspx
  695. */
  696. public function deleteContainer($container, $options = null)
  697. {
  698. Validate::isString($container, 'container');
  699. Validate::notNullOrEmpty($container, 'container');
  700. $method = Resources::HTTP_DELETE;
  701. $headers = array();
  702. $postParams = array();
  703. $queryParams = array();
  704. $path = $container;
  705. $statusCode = Resources::STATUS_ACCEPTED;
  706. if (is_null($options)) {
  707. $options = new DeleteContainerOptions();
  708. }
  709. $headers = $this->addOptionalAccessConditionHeader(
  710. $headers, $options->getAccessCondition()
  711. );
  712. $this->addOptionalQueryParam(
  713. $queryParams,
  714. Resources::QP_TIMEOUT,
  715. $options->getTimeout()
  716. );
  717. $this->addOptionalQueryParam(
  718. $queryParams,
  719. Resources::QP_REST_TYPE,
  720. 'container'
  721. );
  722. $this->send(
  723. $method,
  724. $headers,
  725. $queryParams,
  726. $postParams,
  727. $path,
  728. $statusCode
  729. );
  730. }
  731. /**
  732. * Returns all properties and metadata on the container.
  733. *
  734. * @param string $container name
  735. * @param Models\BlobServiceOptions $options optional parameters
  736. *
  737. * @return Models\GetContainerPropertiesResult
  738. *
  739. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179370.aspx
  740. */
  741. public function getContainerProperties($container, $options = null)
  742. {
  743. return $this->_getContainerPropertiesImpl($container, $options);
  744. }
  745. /**
  746. * Returns only user-defined metadata for the specified container.
  747. *
  748. * @param string $container name
  749. * @param Models\BlobServiceOptions $options optional parameters
  750. *
  751. * @return Models\GetContainerPropertiesResult
  752. *
  753. * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691976.aspx
  754. */
  755. public function getContainerMetadata($container, $options = null)
  756. {
  757. return $this->_getContainerPropertiesImpl($container, $options, 'metadata');
  758. }
  759. /**
  760. * Gets the access control list (ACL) and any container-level access policies
  761. * for the container.
  762. *
  763. * @param string $container The container name.
  764. * @param Models\BlobServiceOptions $options The optional parameters.
  765. *
  766. * @return Models\GetContainerAclResult
  767. *
  768. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179469.aspx
  769. */
  770. public function getContainerAcl($container, $options = null)
  771. {
  772. Validate::isString($container, 'container');
  773. $method = Resources::HTTP_GET;
  774. $headers = array();
  775. $postParams = array();
  776. $queryParams = array();
  777. $path = $container;
  778. $statusCode = Resources::STATUS_OK;
  779. if (is_null($options)) {
  780. $options = new BlobServiceOptions();
  781. }
  782. $this->addOptionalQueryParam(
  783. $queryParams,
  784. Resources::QP_TIMEOUT,
  785. $options->getTimeout()
  786. );
  787. $this->addOptionalQueryParam(
  788. $queryParams,
  789. Resources::QP_REST_TYPE,
  790. 'container'
  791. );
  792. $this->addOptionalQueryParam(
  793. $queryParams,
  794. Resources::QP_COMP,
  795. 'acl'
  796. );
  797. $response = $this->send(
  798. $method,
  799. $headers,
  800. $queryParams,
  801. $postParams,
  802. $path,
  803. $statusCode
  804. );
  805. $access = $response->getHeader(Resources::X_MS_BLOB_PUBLIC_ACCESS);
  806. $etag = $response->getHeader(Resources::ETAG);
  807. $modified = $response->getHeader(Resources::LAST_MODIFIED);
  808. $modifiedDate = Utilities::convertToDateTime($modified);
  809. $parsed = $this->dataSerializer->unserialize($response->getBody());
  810. return GetContainerAclResult::create($access, $etag, $modifiedDate, $parsed);
  811. }
  812. /**
  813. * Sets the ACL and any container-level access policies for the container.
  814. *
  815. * @param string $container name
  816. * @param Models\ContainerAcl $acl access control list for container
  817. * @param Models\BlobServiceOptions $options optional parameters
  818. *
  819. * @return none
  820. *
  821. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179391.aspx
  822. */
  823. public function setContainerAcl($container, $acl, $options = null)
  824. {
  825. Validate::isString($container, 'container');
  826. Validate::notNullOrEmpty($acl, 'acl');
  827. $method = Resources::HTTP_PUT;
  828. $headers = array();
  829. $postParams = array();
  830. $queryParams = array();
  831. $path = $container;
  832. $statusCode = Resources::STATUS_OK;
  833. $body = $acl->toXml($this->dataSerializer);
  834. if (is_null($options)) {
  835. $options = new BlobServiceOptions();
  836. }
  837. $this->addOptionalQueryParam(
  838. $queryParams,
  839. Resources::QP_TIMEOUT,
  840. $options->getTimeout()
  841. );
  842. $this->addOptionalQueryParam(
  843. $queryParams,
  844. Resources::QP_REST_TYPE,
  845. 'container'
  846. );
  847. $this->addOptionalQueryParam(
  848. $queryParams,
  849. Resources::QP_COMP,
  850. 'acl'
  851. );
  852. $this->addOptionalHeader(
  853. $headers,
  854. Resources::X_MS_BLOB_PUBLIC_ACCESS,
  855. $acl->getPublicAccess()
  856. );
  857. $this->addOptionalHeader(
  858. $headers,
  859. Resources::CONTENT_TYPE,
  860. Resources::URL_ENCODED_CONTENT_TYPE
  861. );
  862. $this->send(
  863. $method,
  864. $headers,
  865. $queryParams,
  866. $postParams,
  867. $path,
  868. $statusCode,
  869. $body
  870. );
  871. }
  872. /**
  873. * Sets metadata headers on the container.
  874. *
  875. * @param string $container name
  876. * @param array $metadata metadata key/value pair.
  877. * @param Models\SetContainerMetadataOptions $options optional parameters
  878. *
  879. * @return none
  880. *
  881. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179362.aspx
  882. */
  883. public function setContainerMetadata($container, $metadata, $options = null)
  884. {
  885. Validate::isString($container, 'container');
  886. $this->validateMetadata($metadata);
  887. $method = Resources::HTTP_PUT;
  888. $headers = $this->generateMetadataHeaders($metadata);
  889. $postParams = array();
  890. $queryParams = array();
  891. $path = $container;
  892. $statusCode = Resources::STATUS_OK;
  893. if (is_null($options)) {
  894. $options = new SetContainerMetadataOptions();
  895. }
  896. $this->addOptionalQueryParam(
  897. $queryParams,
  898. Resources::QP_TIMEOUT,
  899. $options->getTimeout()
  900. );
  901. $this->addOptionalQueryParam(
  902. $queryParams,
  903. Resources::QP_REST_TYPE,
  904. 'container'
  905. );
  906. $this->addOptionalQueryParam(
  907. $queryParams,
  908. Resources::QP_COMP,
  909. 'metadata'
  910. );
  911. $headers = $this->addOptionalAccessConditionHeader(
  912. $headers,
  913. $options->getAccessCondition()
  914. );
  915. $this->send(
  916. $method,
  917. $headers,
  918. $queryParams,
  919. $postParams,
  920. $path,
  921. $statusCode
  922. );
  923. }
  924. /**
  925. * Lists all of the blobs in the given container.
  926. *
  927. * @param string $container The container name.
  928. * @param Models\ListBlobsOptions $options The optional parameters.
  929. *
  930. * @return Models\ListBlobsResult
  931. *
  932. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd135734.aspx
  933. */
  934. public function listBlobs($container, $options = null)
  935. {
  936. Validate::isString($container, 'container');
  937. $method = Resources::HTTP_GET;
  938. $headers = array();
  939. $postParams = array();
  940. $queryParams = array();
  941. $path = $container;
  942. $statusCode = Resources::STATUS_OK;
  943. if (is_null($options)) {
  944. $options = new ListBlobsOptions();
  945. }
  946. $this->addOptionalQueryParam(
  947. $queryParams,
  948. Resources::QP_TIMEOUT,
  949. $options->getTimeout()
  950. );
  951. $this->addOptionalQueryParam(
  952. $queryParams,
  953. Resources::QP_REST_TYPE,
  954. 'container'
  955. );
  956. $this->addOptionalQueryParam(
  957. $queryParams,
  958. Resources::QP_COMP,
  959. 'list'
  960. );
  961. $this->addOptionalQueryParam(
  962. $queryParams,
  963. Resources::QP_PREFIX,
  964. $options->getPrefix()
  965. );
  966. $this->addOptionalQueryParam(
  967. $queryParams,
  968. Resources::QP_MARKER,
  969. $options->getMarker()
  970. );
  971. $this->addOptionalQueryParam(
  972. $queryParams,
  973. Resources::QP_DELIMITER,
  974. $options->getDelimiter()
  975. );
  976. $this->addOptionalQueryParam(
  977. $queryParams,
  978. Resources::QP_MAX_RESULTS,
  979. $options->getMaxResults()
  980. );
  981. $includeMetadata = $options->getIncludeMetadata();
  982. $includeSnapshots = $options->getIncludeSnapshots();
  983. $includeUncommittedBlobs = $options->getIncludeUncommittedBlobs();
  984. $includeValue = $this->groupQueryValues(
  985. array(
  986. $includeMetadata ? 'metadata' : null,
  987. $includeSnapshots ? 'snapshots' : null,
  988. $includeUncommittedBlobs ? 'uncommittedblobs' : null
  989. )
  990. );
  991. $this->addOptionalQueryParam(
  992. $queryParams,
  993. Resources::QP_INCLUDE,
  994. $includeValue
  995. );
  996. $response = $this->send(
  997. $method,
  998. $headers,
  999. $queryParams,
  1000. $postParams,
  1001. $path,
  1002. $statusCode
  1003. );
  1004. $parsed = $this->dataSerializer->unserialize($response->getBody());
  1005. return ListBlobsResult::create($parsed);
  1006. }
  1007. /**
  1008. * Creates a new page blob. Note that calling createPageBlob to create a page
  1009. * blob only initializes the blob.
  1010. * To add content to a page blob, call createBlobPages method.
  1011. *
  1012. * @param string $container The container name.
  1013. * @param string $blob The blob name.
  1014. * @param integer $length Specifies the maximum size for the
  1015. * page blob, up to 1 TB. The page blob size must be aligned to a 512-byte
  1016. * boundary.
  1017. * @param Models\CreateBlobOptions $options The optional parameters.
  1018. *
  1019. * @return CopyBlobResult
  1020. *
  1021. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
  1022. */
  1023. public function createPageBlob($container, $blob, $length, $options = null)
  1024. {
  1025. Validate::isString($container, 'container');
  1026. Validate::isString($blob, 'blob');
  1027. Validate::notNullOrEmpty($blob, 'blob');
  1028. Validate::isInteger($length, 'length');
  1029. Validate::notNull($length, 'length');
  1030. $method = Resources::HTTP_PUT;
  1031. $headers = array();
  1032. $postParams = array();
  1033. $queryParams = array();
  1034. $path = $this->_createPath($container, $blob);
  1035. $statusCode = Resources::STATUS_CREATED;
  1036. if (is_null($options)) {
  1037. $options = new CreateBlobOptions();
  1038. }
  1039. $this->addOptionalHeader(
  1040. $headers,
  1041. Resources::X_MS_BLOB_TYPE,
  1042. BlobType::PAGE_BLOB
  1043. );
  1044. $this->addOptionalHeader(
  1045. $headers,
  1046. Resources::X_MS_BLOB_CONTENT_LENGTH,
  1047. $length
  1048. );
  1049. $this->addOptionalHeader(
  1050. $headers,
  1051. Resources::X_MS_BLOB_SEQUENCE_NUMBER,
  1052. $options->getSequenceNumber()
  1053. );
  1054. $headers = $this->_addCreateBlobOptionalHeaders($options, $headers);
  1055. $this->addOptionalQueryParam(
  1056. $queryParams,
  1057. Resources::QP_TIMEOUT,
  1058. $options->getTimeout()
  1059. );
  1060. $response = $this->send(
  1061. $method,
  1062. $headers,
  1063. $queryParams,
  1064. $postParams,
  1065. $path,
  1066. $statusCode
  1067. );
  1068. return CopyBlobResult::create($response->getHeader());
  1069. }
  1070. /**
  1071. * Creates a new block blob or updates the content of an existing block blob.
  1072. *
  1073. * Updating an existing block blob overwrites any existing metadata on the blob.
  1074. * Partial updates are not supported with createBlockBlob the content of the
  1075. * existing blob is overwritten with the content of the new blob. To perform a
  1076. * partial update of the content o f a block blob, use the createBlockList
  1077. * method.
  1078. * Note that the default content type is application/octet-stream.
  1079. *
  1080. * @param string $container The name of the container.
  1081. * @param string $blob The name of the blob.
  1082. * @param string|resource $content The content of the blob.
  1083. * @param Models\CreateBlobOptions $options The optional parameters.
  1084. *
  1085. * @return CopyBlobResult
  1086. *
  1087. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
  1088. */
  1089. public function createBlockBlob($container, $blob, $content, $options = null)
  1090. {
  1091. Validate::isString($container, 'container');
  1092. Validate::isString($blob, 'blob');
  1093. Validate::notNullOrEmpty($blob, 'blob');
  1094. Validate::isTrue(
  1095. is_string($content) || is_resource($content),
  1096. sprintf(Resources::INVALID_PARAM_MSG, 'content', 'string|resource')
  1097. );
  1098. $method = Resources::HTTP_PUT;
  1099. $headers = array();
  1100. $postParams = array();
  1101. $queryParams = array();
  1102. $path = $this->_createPath($container, $blob);
  1103. $statusCode = Resources::STATUS_CREATED;
  1104. // If read file failed for any reason it will throw an exception.
  1105. $body = is_resource($content) ? stream_get_contents($content) : $content;
  1106. if (is_null($options)) {
  1107. $options = new CreateBlobOptions();
  1108. }
  1109. $headers = $this->_addCreateBlobOptionalHeaders($options, $headers);
  1110. $this->addOptionalHeader(
  1111. $headers,
  1112. Resources::X_MS_BLOB_TYPE,
  1113. BlobType::BLOCK_BLOB
  1114. );
  1115. $this->addOptionalQueryParam(
  1116. $queryParams,
  1117. Resources::QP_TIMEOUT,
  1118. $options->getTimeout()
  1119. );
  1120. $response = $this->send(
  1121. $method,
  1122. $headers,
  1123. $queryParams,
  1124. $postParams,
  1125. $path,
  1126. $statusCode,
  1127. $body
  1128. );
  1129. return CopyBlobResult::create($response->getHeader());
  1130. }
  1131. /**
  1132. * Clears a range of pages from the blob.
  1133. *
  1134. * @param string $container name of the container
  1135. * @param string $blob name of the blob
  1136. * @param Models\PageRange $range Can be up to the value of the
  1137. * blob's full size. Note that ranges must be aligned to 512 (0-511, 512-1023)
  1138. * @param Models\CreateBlobPagesOptions $options optional parameters
  1139. *
  1140. * @return Models\CreateBlobPagesResult.
  1141. *
  1142. * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx
  1143. */
  1144. public function clearBlobPages($container, $blob, $range, $options = null)
  1145. {
  1146. return $this->_updatePageBlobPagesImpl(
  1147. PageWriteOption::CLEAR_OPTION,
  1148. $container,
  1149. $blob,
  1150. $range,
  1151. Resources::EMPTY_STRING,
  1152. $options
  1153. );
  1154. }
  1155. /**
  1156. * Creates a range of pages to a page blob.
  1157. *
  1158. * @param string $container name of the container
  1159. * @param string $blob name of the blob
  1160. * @param Models\PageRange $range Can be up to 4 MB in size
  1161. * Note that ranges must be aligned to 512 (0-511, 512-1023)
  1162. * @param string $content the blob contents.
  1163. * @param Models\CreateBlobPagesOptions $options optional parameters
  1164. *
  1165. * @return Models\CreateBlobPagesResult.
  1166. *
  1167. * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx
  1168. */
  1169. public function createBlobPages($container, $blob, $range, $content,
  1170. $options = null
  1171. ) {
  1172. return $this->_updatePageBlobPagesImpl(
  1173. PageWriteOption::UPDATE_OPTION,
  1174. $container,
  1175. $blob,
  1176. $range,
  1177. $content,
  1178. $options
  1179. );
  1180. }
  1181. /**
  1182. * Creates a new block to be committed as part of a block blob.
  1183. *
  1184. * @param string $container name of the container
  1185. * @param string $blob name of the blob
  1186. * @param string $blockId must be less than or equal to
  1187. * 64 bytes in size. For a given blob, the length of the value specified for the
  1188. * blockid parameter must be the same size for each block.
  1189. * @param string $content the blob block contents
  1190. * @param Models\CreateBlobBlockOptions $options optional parameters
  1191. *
  1192. * @return none
  1193. *
  1194. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd135726.aspx
  1195. */
  1196. public function createBlobBlock($container, $blob, $blockId, $content,
  1197. $options = null
  1198. ) {
  1199. Validate::isString($container, 'container');
  1200. Validate::isString($blob, 'blob');
  1201. Validate::notNullOrEmpty($blob, 'blob');
  1202. Validate::isString($blockId, 'blockId');
  1203. Validate::notNullOrEmpty($blockId, 'blockId');
  1204. Validate::isTrue(
  1205. is_string($content) || is_resource($content),
  1206. sprintf(Resources::INVALID_PARAM_MSG, 'content', 'string|resource')
  1207. );
  1208. $method = Resources::HTTP_PUT;
  1209. $headers = array();
  1210. $postParams = array();
  1211. $queryParams = array();
  1212. $path = $this->_createPath($container, $blob);
  1213. $statusCode = Resources::STATUS_CREATED;
  1214. $body = $content;
  1215. if (is_null($options)) {
  1216. $options = new CreateBlobBlockOptions();
  1217. }
  1218. $this->addOptionalHeader(
  1219. $headers,
  1220. Resources::X_MS_LEASE_ID,
  1221. $options->getLeaseId()
  1222. );
  1223. $this->addOptionalHeader(
  1224. $headers,
  1225. Resources::CONTENT_MD5,
  1226. $options->getContentMD5()
  1227. );
  1228. $this->addOptionalHeader(
  1229. $headers,
  1230. Resources::CONTENT_TYPE,
  1231. Resources::URL_ENCODED_CONTENT_TYPE
  1232. );
  1233. $this->addOptionalQueryParam(
  1234. $queryParams,
  1235. Resources::QP_TIMEOUT,
  1236. $options->getTimeout()
  1237. );
  1238. $this->addOptionalQueryParam(
  1239. $queryParams,
  1240. Resources::QP_COMP,
  1241. 'block'
  1242. );
  1243. $this->addOptionalQueryParam(
  1244. $queryParams,
  1245. Resources::QP_BLOCKID,
  1246. base64_encode($blockId)
  1247. );
  1248. $this->send(
  1249. $method,
  1250. $headers,
  1251. $queryParams,
  1252. $postParams,
  1253. $path,
  1254. $statusCode,
  1255. $body
  1256. );
  1257. }
  1258. /**
  1259. * This method writes a blob by specifying the list of block IDs that make up the
  1260. * blob. In order to be written as part of a blob, a block must have been
  1261. * successfully written to the server in a prior createBlobBlock method.
  1262. *
  1263. * You can call Put Block List to update a blob by uploading only those blocks
  1264. * that have changed, then committing the new and existing blocks together.
  1265. * You can do this by specifying whether to commit a block from the committed
  1266. * block list or from the uncommitted block list, or to commit the most recently
  1267. * uploaded version of the block, whichever list it may belong to.
  1268. *
  1269. * @param string $container The container name.
  1270. * @param string $blob The blob name.
  1271. * @param Models\BlockList|array $blockList The block entries.
  1272. * @param Models\CommitBlobBlocksOptions $options The optional parameters.
  1273. *
  1274. * @return none
  1275. *
  1276. * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179467.aspx
  1277. */
  1278. public function commitBlobBlocks($container, $blob, $blockList, $options = null)
  1279. {
  1280. Validate::isString($container, 'container');
  1281. Validate::isString($blob, 'blob');
  1282. Validate::notNullOrEmpty($blob, 'blob');
  1283. Validate::isTrue(
  1284. $blockList instanceof BlockList || is_array($blockList),
  1285. sprintf(
  1286. Resources::INVALID_PARAM_MSG,
  1287. 'blockList',
  1288. get_class(new BlockList())
  1289. )
  1290. );
  1291. $method = Resources::HTTP_PUT;
  1292. $headers = array();
  1293. $postParams = array();
  1294. $queryParams = array();
  1295. $path = $this->_createPath($container, $blob);
  1296. $statusCode = Resources::STATUS_CREATED;
  1297. $isArray = is_array($blockList);
  1298. $blockList = $isArray ? BlockList::create($blockList) : $blockList;
  1299. $body = $blockList->toXml($this->dataSerializer);
  1300. if (is_null($options)) {
  1301. $options = new CommitBlobBlocksOptions();
  1302. }
  1303. $blobContentType = $options->getBlobContentType();
  1304. $blobContentEncoding = $options->getBlobContentEncoding();
  1305. $blobContentLanguage = $options->getBlobContentLanguage();
  1306. $blobContentMD5 = $options->getBlobContentMD5();
  1307. $blobCacheControl = $options->getBlobCacheControl();
  1308. $leaseId = $options->getLeaseId();
  1309. $contentType = Resources::URL_ENCODED_CONTENT_TYPE;
  1310. $metadata = $options->getMetadata();
  1311. $headers = $this->generateMetadataHeaders($metadata);
  1312. $headers = $this->addOptionalAccessConditionHeader(
  1313. $headers, $options->getAccessCondition()
  1314. );
  1315. $this->addOptionalHeader(
  1316. $headers,
  1317. Resources::X_MS_LEASE_ID,
  1318. $leaseId
  1319. );
  1320. $this->addOptionalHeader(
  1321. $headers,
  1322. Resources::X_MS_BLOB_CACHE_CONTROL,
  1323. $blobCacheControl
  1324. );
  1325. $this->addOptionalHeader(
  1326. $headers,
  1327. Resources::X_MS_BLOB_CONTENT_TYPE,
  1328. $blobContentType
  1329. );
  1330. $this->addOptionalHeader(
  1331. $headers,
  1332. Resources::X_MS_BLOB_CONTENT_ENCODING,
  1333. $blobContentEncoding
  1334. );
  1335. $this->addOptionalHeader(
  1336. $headers,
  1337. Resources::X_MS_BLOB_CONTENT_LANGUAGE,
  1338. $blobContentLanguage
  1339. );
  1340. $this->addOptionalHeader(
  1341. $headers,
  1342. Resources::X_MS_BLOB_CONTENT_MD5,
  1343. $blobContentMD5
  1344. );
  1345. $this->addOptionalHeader(
  1346. $headers,
  1347. Resources::CONTENT_TYPE,
  1348. $contentType
  1349. );
  1350. $this->addOptionalQueryParam(
  1351. $queryParams,
  1352. Resources::QP_TIMEOUT,
  1353. $options->getTimeout()
  1354. );
  1355. $this->addOptionalQueryParam(
  1356. $queryParams,
  1357. Resources::QP_COMP,
  1358. 'blocklist'
  1359. );
  1360. $this->send(
  1361. $method,
  1362. $headers,
  1363. $queryParams,
  1364. $postParams,
  1365. $path,