/** * @covers WindowsAzure\Blob\Models\CopyBlobResult::getLastModified * @covers WindowsAzure\Blob\Models\CopyBlobResult::setLastModified */ public function testSetLastModified() { $createBlobSnapshotResult = new CopyBlobResult(); $expected = new \DateTime("2008-8-8"); $createBlobSnapshotResult->setLastModified($expected); $this->assertEquals($expected, $createBlobSnapshotResult->getLastModified()); }
/** * Creates CopyBlobResult object from the response of the copy blob request. * * @param array $headers The HTTP response headers in array representation. * * @return CopyBlobResult */ public static function create($headers) { $result = new CopyBlobResult(); $headerWithLowerCaseKey = array_change_key_case($headers); $result->setEtag($headerWithLowerCaseKey[Resources::ETAG]); $result->setLastModified(Utilities::rfc1123ToDateTime($headerWithLowerCaseKey[Resources::LAST_MODIFIED])); return $result; }
/** * Creates CopyBlobResult object from the response of the copy blob request. * * @param array $headers The HTTP response headers in array representation. * * @return CopyBlobResult */ public static function create($headers) { $result = new CopyBlobResult(); $result->setETag(Utilities::tryGetValueInsensitive(Resources::ETAG, $headers)); if (Utilities::arrayKeyExistsInsensitive(Resources::LAST_MODIFIED, $headers)) { $lastModified = Utilities::tryGetValueInsensitive(Resources::LAST_MODIFIED, $headers); $result->setLastModified(Utilities::rfc1123ToDateTime($lastModified)); } return $result; }
/** * Copies a source blob to a destination blob within the same storage account. * * @param string $destinationContainer name of the destination * container * @param string $destinationBlob name of the destination * blob * @param string $sourceContainer name of the source * container * @param string $sourceBlob name of the source * blob * @param Models\CopyBlobOptions $options optional parameters * * @return CopyBlobResult * * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd894037.aspx */ public function copyBlob($destinationContainer, $destinationBlob, $sourceContainer, $sourceBlob, $options = null) { $method = Resources::HTTP_PUT; $headers = array(); $postParams = array(); $queryParams = array(); $destinationBlobPath = $this->_createPath($destinationContainer, $destinationBlob); $statusCode = Resources::STATUS_CREATED; if (is_null($options)) { $options = new CopyBlobOptions(); } $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout()); $sourceBlobPath = $this->_getCopyBlobSourceName($sourceContainer, $sourceBlob, $options); $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition()); $headers = $this->addOptionalSourceAccessConditionHeader($headers, $options->getSourceAccessCondition()); $this->addOptionalHeader($headers, Resources::X_MS_COPY_SOURCE, $sourceBlobPath); $headers = $this->addMetadataHeaders($headers, $options->getMetadata()); $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId()); $this->addOptionalHeader($headers, Resources::X_MS_SOURCE_LEASE_ID, $options->getSourceLeaseId()); $response = $this->send($method, $headers, $queryParams, $postParams, $destinationBlobPath, $statusCode); return CopyBlobResult::create($response->getHeader()); }