Integrate Response<T> into Storage Blobs Service (#327)
* Revert changes to storage code * adapt to breaking changes in Azure::Core, Response->RawResponse, pipeline clone returns unique_ptr * just to make build pass, remove this commit after https://github.com/Azure/azure-sdk-for-cpp/pull/326 is merged * adapt to Response<T> * concurrent upload/download also return Response<T> * add BlobInfo and BlobContainerInfo
This commit is contained in:
parent
1a9918c4db
commit
4d19f3b078
@ -21,8 +21,6 @@ namespace Azure { namespace Core {
|
||||
// Do not give up raw response ownership.
|
||||
Http::RawResponse& GetRawResponse() { return *this->m_rawResponse; }
|
||||
|
||||
T& operator=(const Response& other) = delete;
|
||||
|
||||
const T* operator->() const { return &this->m_value; };
|
||||
T* operator->() { return &this->m_value; };
|
||||
T& operator*() { return this->m_value; };
|
||||
|
||||
@ -104,7 +104,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A BlobContentInfo describing the newly
|
||||
* created append blob.
|
||||
*/
|
||||
BlobContentInfo Create(const CreateAppendBlobOptions& options = CreateAppendBlobOptions());
|
||||
Azure::Core::Response<BlobContentInfo> Create(
|
||||
const CreateAppendBlobOptions& options = CreateAppendBlobOptions());
|
||||
|
||||
/**
|
||||
* @brief Commits a new block of data, represented by the content BodyStream to the end
|
||||
@ -116,7 +117,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* function.
|
||||
* @return A BlobAppendInfo describing the state of the updated append blob.
|
||||
*/
|
||||
BlobAppendInfo AppendBlock(
|
||||
Azure::Core::Response<BlobAppendInfo> AppendBlock(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const AppendBlockOptions& options = AppendBlockOptions());
|
||||
|
||||
@ -133,7 +134,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A BlobAppendInfo describing the
|
||||
* state of the updated append blob.
|
||||
*/
|
||||
BlobAppendInfo AppendBlockFromUri(
|
||||
Azure::Core::Response<BlobAppendInfo> AppendBlockFromUri(
|
||||
const std::string& sourceUri,
|
||||
const AppendBlockFromUriOptions& options = AppendBlockFromUriOptions()) const;
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A BlobProperties
|
||||
* describing the blob's properties.
|
||||
*/
|
||||
BlobProperties GetProperties(
|
||||
Azure::Core::Response<BlobProperties> GetProperties(
|
||||
const GetBlobPropertiesOptions& options = GetBlobPropertiesOptions()) const;
|
||||
|
||||
/**
|
||||
@ -160,7 +160,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A SetBlobHttpHeadersResponse describing the updated blob.
|
||||
*/
|
||||
SetBlobHttpHeadersResponse SetHttpHeaders(
|
||||
Azure::Core::Response<BlobInfo> SetHttpHeaders(
|
||||
BlobHttpHeaders httpHeaders,
|
||||
const SetBlobHttpHeadersOptions& options = SetBlobHttpHeadersOptions()) const;
|
||||
|
||||
@ -173,7 +173,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* options Optional parameters to execute this function.
|
||||
* @return A SetBlobMetadataResponse describing the updated blob.
|
||||
*/
|
||||
SetBlobMetadataResponse SetMetadata(
|
||||
Azure::Core::Response<BlobInfo> SetMetadata(
|
||||
std::map<std::string, std::string> metadata,
|
||||
const SetBlobMetadataOptions& options = SetBlobMetadataOptions()) const;
|
||||
|
||||
@ -186,7 +186,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* parameters to execute this function.
|
||||
* @return A SetAccessTierResponse on successfully setting the tier.
|
||||
*/
|
||||
SetAccessTierResponse SetAccessTier(
|
||||
Azure::Core::Response<SetAccessTierResponse> SetAccessTier(
|
||||
AccessTier Tier,
|
||||
const SetAccessTierOptions& options = SetAccessTierOptions()) const;
|
||||
|
||||
@ -202,7 +202,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobCopyInfo describing the state of the copy operation.
|
||||
*/
|
||||
BlobCopyInfo StartCopyFromUri(
|
||||
Azure::Core::Response<BlobCopyInfo> StartCopyFromUri(
|
||||
const std::string& sourceUri,
|
||||
const StartCopyFromUriOptions& options = StartCopyFromUriOptions()) const;
|
||||
|
||||
@ -214,7 +214,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A AbortCopyBlobResponse on successfully aborting.
|
||||
*/
|
||||
AbortCopyBlobResponse AbortCopyFromUri(
|
||||
Azure::Core::Response<AbortCopyBlobResponse> AbortCopyFromUri(
|
||||
const std::string& copyId,
|
||||
const AbortCopyFromUriOptions& options = AbortCopyFromUriOptions()) const;
|
||||
|
||||
@ -226,7 +226,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A BlobDownloadResponse describing the downloaded blob.
|
||||
* BlobDownloadResponse.BodyStream contains the blob's data.
|
||||
*/
|
||||
BlobDownloadResponse Download(const DownloadBlobOptions& options = DownloadBlobOptions()) const;
|
||||
Azure::Core::Response<BlobDownloadResponse> Download(
|
||||
const DownloadBlobOptions& options = DownloadBlobOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Downloads a blob or a blob range from the service to a memory buffer using parallel
|
||||
@ -239,7 +240,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A
|
||||
* BlobDownloadInfo describing the downloaded blob.
|
||||
*/
|
||||
BlobDownloadInfo DownloadToBuffer(
|
||||
Azure::Core::Response<BlobDownloadInfo> DownloadToBuffer(
|
||||
uint8_t* buffer,
|
||||
std::size_t bufferSize,
|
||||
const DownloadBlobToBufferOptions& options = DownloadBlobToBufferOptions()) const;
|
||||
@ -253,7 +254,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A
|
||||
* BlobDownloadInfo describing the downloaded blob.
|
||||
*/
|
||||
BlobDownloadInfo DownloadToFile(
|
||||
Azure::Core::Response<BlobDownloadInfo> DownloadToFile(
|
||||
const std::string& file,
|
||||
const DownloadBlobToFileOptions& options = DownloadBlobToFileOptions()) const;
|
||||
|
||||
@ -265,7 +266,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A BlobSnapshotInfo describing the new
|
||||
* blob snapshot.
|
||||
*/
|
||||
BlobSnapshotInfo CreateSnapshot(
|
||||
Azure::Core::Response<BlobSnapshotInfo> CreateSnapshot(
|
||||
const CreateSnapshotOptions& options = CreateSnapshotOptions()) const;
|
||||
|
||||
/**
|
||||
@ -276,7 +277,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A DeleteBlobResponse on successfully deleting.
|
||||
*/
|
||||
DeleteBlobResponse Delete(const DeleteBlobOptions& options = DeleteBlobOptions()) const;
|
||||
Azure::Core::Response<DeleteBlobResponse> Delete(
|
||||
const DeleteBlobOptions& options = DeleteBlobOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Restores the contents and metadata of a soft deleted blob and any associated
|
||||
@ -286,7 +288,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* function.
|
||||
* @return A UndeleteBlobResponse on successfully deleting.
|
||||
*/
|
||||
UndeleteBlobResponse Undelete(const UndeleteBlobOptions& options = UndeleteBlobOptions()) const;
|
||||
Azure::Core::Response<UndeleteBlobResponse> Undelete(
|
||||
const UndeleteBlobOptions& options = UndeleteBlobOptions()) const;
|
||||
|
||||
protected:
|
||||
UriBuilder m_blobUrl;
|
||||
|
||||
@ -134,7 +134,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A BlobContainerInfo describing the newly
|
||||
* created blob container.
|
||||
*/
|
||||
BlobContainerInfo Create(
|
||||
Azure::Core::Response<BlobContainerInfo> Create(
|
||||
const CreateBlobContainerOptions& options = CreateBlobContainerOptions()) const;
|
||||
|
||||
/**
|
||||
@ -145,7 +145,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* options Optional parameters to execute this function.
|
||||
* @return A DeleteContainerResponse if successful.
|
||||
*/
|
||||
DeleteContainerResponse Delete(
|
||||
Azure::Core::Response<DeleteContainerResponse> Delete(
|
||||
const DeleteBlobContainerOptions& options = DeleteBlobContainerOptions()) const;
|
||||
|
||||
/**
|
||||
@ -156,7 +156,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A
|
||||
* BlobContainerProperties describing the container and its properties.
|
||||
*/
|
||||
BlobContainerProperties GetProperties(
|
||||
Azure::Core::Response<BlobContainerProperties> GetProperties(
|
||||
const GetBlobContainerPropertiesOptions& options
|
||||
= GetBlobContainerPropertiesOptions()) const;
|
||||
|
||||
@ -168,7 +168,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* Optional parameters to execute this function.
|
||||
* @return A SetContainerMetadataResponse if successful.
|
||||
*/
|
||||
SetContainerMetadataResponse SetMetadata(
|
||||
Azure::Core::Response<BlobContainerInfo> SetMetadata(
|
||||
std::map<std::string, std::string> metadata,
|
||||
SetBlobContainerMetadataOptions options = SetBlobContainerMetadataOptions()) const;
|
||||
|
||||
@ -182,7 +182,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A
|
||||
* BlobsFlatSegment describing a segment of the blobs in the container.
|
||||
*/
|
||||
BlobsFlatSegment ListBlobsFlat(const ListBlobsOptions& options = ListBlobsOptions()) const;
|
||||
Azure::Core::Response<BlobsFlatSegment> ListBlobsFlat(
|
||||
const ListBlobsOptions& options = ListBlobsOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Returns a single segment of blobs in this container, starting from the
|
||||
@ -197,7 +198,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobsFlatSegment describing a segment of the blobs in the container.
|
||||
*/
|
||||
BlobsHierarchySegment ListBlobsByHierarchy(
|
||||
Azure::Core::Response<BlobsHierarchySegment> ListBlobsByHierarchy(
|
||||
const std::string& delimiter,
|
||||
const ListBlobsOptions& options = ListBlobsOptions()) const;
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A
|
||||
* ListContainersSegment describing segment of the blob containers in the storage account.
|
||||
*/
|
||||
ListContainersSegment ListBlobContainersSegment(
|
||||
Azure::Core::Response<ListContainersSegment> ListBlobContainersSegment(
|
||||
const ListBlobContainersOptions& options = ListBlobContainersOptions()) const;
|
||||
|
||||
/**
|
||||
@ -118,7 +118,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* this function.
|
||||
* @return A deserialized UserDelegationKey instance.
|
||||
*/
|
||||
UserDelegationKey GetUserDelegationKey(
|
||||
Azure::Core::Response<UserDelegationKey> GetUserDelegationKey(
|
||||
const std::string& startsOn,
|
||||
const std::string& expiresOn,
|
||||
const GetUserDelegationKeyOptions& options = GetUserDelegationKeyOptions()) const;
|
||||
|
||||
@ -109,7 +109,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobContentInfo describing the state of the updated block blob.
|
||||
*/
|
||||
BlobContentInfo Upload(
|
||||
Azure::Core::Response<BlobContentInfo> Upload(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const UploadBlockBlobOptions& options = UploadBlockBlobOptions()) const;
|
||||
|
||||
@ -122,7 +122,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobContentInfo describing the state of the updated block blob.
|
||||
*/
|
||||
BlobContentInfo UploadFromBuffer(
|
||||
Azure::Core::Response<BlobContentInfo> UploadFromBuffer(
|
||||
const uint8_t* buffer,
|
||||
std::size_t bufferSize,
|
||||
const UploadBlobOptions& options = UploadBlobOptions()) const;
|
||||
@ -135,7 +135,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobContentInfo describing the state of the updated block blob.
|
||||
*/
|
||||
BlobContentInfo UploadFromFile(
|
||||
Azure::Core::Response<BlobContentInfo> UploadFromFile(
|
||||
const std::string& file,
|
||||
const UploadBlobOptions& options = UploadBlobOptions()) const;
|
||||
|
||||
@ -149,7 +149,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlockInfo describing the state of the updated block.
|
||||
*/
|
||||
BlockInfo StageBlock(
|
||||
Azure::Core::Response<BlockInfo> StageBlock(
|
||||
const std::string& blockId,
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const StageBlockOptions& options = StageBlockOptions()) const;
|
||||
@ -167,7 +167,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlockInfo describing the state of the updated block blob.
|
||||
*/
|
||||
BlockInfo StageBlockFromUri(
|
||||
Azure::Core::Response<BlockInfo> StageBlockFromUri(
|
||||
const std::string& blockId,
|
||||
const std::string& sourceUri,
|
||||
const StageBlockFromUriOptions& options = StageBlockFromUriOptions()) const;
|
||||
@ -185,7 +185,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobContentInfo describing the state of the updated block blob.
|
||||
*/
|
||||
BlobContentInfo CommitBlockList(
|
||||
Azure::Core::Response<BlobContentInfo> CommitBlockList(
|
||||
const std::vector<std::pair<BlockType, std::string>>& blockIds,
|
||||
const CommitBlockListOptions& options = CommitBlockListOptions()) const;
|
||||
|
||||
@ -199,7 +199,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobBlockListInfo describing requested block list.
|
||||
*/
|
||||
BlobBlockListInfo GetBlockList(
|
||||
Azure::Core::Response<BlobBlockListInfo> GetBlockList(
|
||||
const GetBlockListOptions& options = GetBlockListOptions()) const;
|
||||
|
||||
private:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -125,7 +125,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobContentInfo describing the newly created page blob.
|
||||
*/
|
||||
BlobContentInfo Create(
|
||||
Azure::Core::Response<BlobContentInfo> Create(
|
||||
int64_t blobContentLength,
|
||||
const CreatePageBlobOptions& options = CreatePageBlobOptions());
|
||||
|
||||
@ -140,7 +140,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A
|
||||
* PageInfo describing the state of the updated pages.
|
||||
*/
|
||||
PageInfo UploadPages(
|
||||
Azure::Core::Response<PageInfo> UploadPages(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
int64_t offset,
|
||||
const UploadPagesOptions& options = UploadPagesOptions());
|
||||
@ -164,7 +164,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A PageInfo describing the state
|
||||
* of the updated pages.
|
||||
*/
|
||||
PageInfo UploadPagesFromUri(
|
||||
Azure::Core::Response<PageInfo> UploadPagesFromUri(
|
||||
std::string sourceUri,
|
||||
int64_t sourceOffset,
|
||||
int64_t sourceLength,
|
||||
@ -181,7 +181,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A PageInfo describing the state of the updated pages.
|
||||
*/
|
||||
PageInfo ClearPages(
|
||||
Azure::Core::Response<PageInfo> ClearPages(
|
||||
int64_t offset,
|
||||
int64_t length,
|
||||
const ClearPagesOptions& options = ClearPagesOptions());
|
||||
@ -196,7 +196,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A PageBlobInfo describing the resized page blob.
|
||||
*/
|
||||
PageBlobInfo Resize(
|
||||
Azure::Core::Response<PageBlobInfo> Resize(
|
||||
int64_t blobContentLength,
|
||||
const ResizePageBlobOptions& options = ResizePageBlobOptions());
|
||||
|
||||
@ -206,7 +206,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A PageRangesInfo describing the valid page ranges for this blob.
|
||||
*/
|
||||
PageRangesInfo GetPageRanges(const GetPageRangesOptions& options = GetPageRangesOptions());
|
||||
Azure::Core::Response<PageRangesInfo> GetPageRanges(
|
||||
const GetPageRangesOptions& options = GetPageRangesOptions());
|
||||
|
||||
/**
|
||||
* @brief Starts copying a snapshot of the sourceUri page blob to this page blob. The snapshot
|
||||
@ -219,7 +220,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A BlobCopyInfo describing the state of the copy operation.
|
||||
*/
|
||||
BlobCopyInfo StartCopyIncremental(
|
||||
Azure::Core::Response<BlobCopyInfo> StartCopyIncremental(
|
||||
const std::string& sourceUri,
|
||||
const IncrementalCopyPageBlobOptions& options = IncrementalCopyPageBlobOptions());
|
||||
|
||||
|
||||
@ -7,4 +7,8 @@
|
||||
namespace Azure { namespace Storage { namespace Details {
|
||||
constexpr static const char* c_HttpQuerySnapshot = "snapshot";
|
||||
constexpr static const char* c_HttpQueryVersionId = "versionid";
|
||||
constexpr static const char* c_HttpHeaderDate = "date";
|
||||
constexpr static const char* c_HttpHeaderXMsVersion = "x-ms-version";
|
||||
constexpr static const char* c_HttpHeaderRequestId = "x-ms-request-id";
|
||||
constexpr static const char* c_HttpHeaderClientRequestId = "x-ms-client-request-id";
|
||||
}}} // namespace Azure::Storage::Details
|
||||
|
||||
@ -10,5 +10,7 @@ namespace Azure { namespace Storage {
|
||||
std::string HMAC_SHA256(const std::string& text, const std::string& key);
|
||||
std::string Base64Encode(const std::string& text);
|
||||
std::string Base64Decode(const std::string& text);
|
||||
std::string MD5(const std::string& text);
|
||||
std::string CRC64(const std::string& text);
|
||||
|
||||
}} // namespace Azure::Storage
|
||||
|
||||
@ -35,7 +35,7 @@ void BlobsGettingStarted()
|
||||
std::map<std::string, std::string> blobMetadata = {{"key1", "value1"}, {"key2", "value2"}};
|
||||
blobClient.SetMetadata(blobMetadata);
|
||||
|
||||
auto properties = blobClient.GetProperties();
|
||||
auto properties = *blobClient.GetProperties();
|
||||
for (auto metadata : properties.Metadata)
|
||||
{
|
||||
std::cout << metadata.first << ":" << metadata.second << std::endl;
|
||||
|
||||
@ -58,7 +58,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return newClient;
|
||||
}
|
||||
|
||||
BlobContentInfo AppendBlobClient::Create(const CreateAppendBlobOptions& options)
|
||||
Azure::Core::Response<BlobContentInfo> AppendBlobClient::Create(
|
||||
const CreateAppendBlobOptions& options)
|
||||
{
|
||||
BlobRestClient::AppendBlob::CreateOptions protocolLayerOptions;
|
||||
protocolLayerOptions.HttpHeaders = options.HttpHeaders;
|
||||
@ -72,7 +73,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobAppendInfo AppendBlobClient::AppendBlock(
|
||||
Azure::Core::Response<BlobAppendInfo> AppendBlobClient::AppendBlock(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const AppendBlockOptions& options)
|
||||
{
|
||||
@ -90,7 +91,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), *content, protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobAppendInfo AppendBlobClient::AppendBlockFromUri(
|
||||
Azure::Core::Response<BlobAppendInfo> AppendBlobClient::AppendBlockFromUri(
|
||||
const std::string& sourceUri,
|
||||
const AppendBlockFromUriOptions& options) const
|
||||
{
|
||||
|
||||
@ -126,7 +126,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return newClient;
|
||||
}
|
||||
|
||||
BlobDownloadResponse BlobClient::Download(const DownloadBlobOptions& options) const
|
||||
Azure::Core::Response<BlobDownloadResponse> BlobClient::Download(
|
||||
const DownloadBlobOptions& options) const
|
||||
{
|
||||
BlobRestClient::Blob::DownloadOptions protocolLayerOptions;
|
||||
if (options.Offset.HasValue() && options.Length.HasValue())
|
||||
@ -150,7 +151,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobDownloadInfo BlobClient::DownloadToBuffer(
|
||||
Azure::Core::Response<BlobDownloadInfo> BlobClient::DownloadToBuffer(
|
||||
uint8_t* buffer,
|
||||
std::size_t bufferSize,
|
||||
const DownloadBlobToBufferOptions& options) const
|
||||
@ -185,8 +186,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
int64_t blobRangeSize;
|
||||
if (firstChunkOptions.Offset.HasValue())
|
||||
{
|
||||
blobSize = std::stoll(firstChunk.ContentRange.GetValue().substr(
|
||||
firstChunk.ContentRange.GetValue().find('/') + 1));
|
||||
blobSize = std::stoll(firstChunk->ContentRange.GetValue().substr(
|
||||
firstChunk->ContentRange.GetValue().find('/') + 1));
|
||||
blobRangeSize = blobSize - firstChunkOffset;
|
||||
if (options.Length.HasValue())
|
||||
{
|
||||
@ -195,7 +196,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
else
|
||||
{
|
||||
blobSize = firstChunk.BodyStream->Length();
|
||||
blobSize = firstChunk->BodyStream->Length();
|
||||
blobRangeSize = blobSize;
|
||||
}
|
||||
firstChunkLength = std::min(firstChunkLength, blobRangeSize);
|
||||
@ -207,25 +208,27 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
|
||||
int64_t bytesRead = Azure::Core::Http::BodyStream::ReadToCount(
|
||||
firstChunkOptions.Context, *firstChunk.BodyStream, buffer, firstChunkLength);
|
||||
firstChunkOptions.Context, *(firstChunk->BodyStream), buffer, firstChunkLength);
|
||||
if (bytesRead != firstChunkLength)
|
||||
{
|
||||
throw std::runtime_error("error when reading body stream");
|
||||
}
|
||||
firstChunk.BodyStream.reset();
|
||||
firstChunk->BodyStream.reset();
|
||||
|
||||
auto returnTypeConverter = [](BlobDownloadResponse& response) {
|
||||
auto returnTypeConverter = [](Azure::Core::Response<BlobDownloadResponse>& response) {
|
||||
BlobDownloadInfo ret;
|
||||
ret.ETag = std::move(response.ETag);
|
||||
ret.LastModified = std::move(response.LastModified);
|
||||
ret.HttpHeaders = std::move(response.HttpHeaders);
|
||||
ret.Metadata = std::move(response.Metadata);
|
||||
ret.BlobType = response.BlobType;
|
||||
ret.ServerEncrypted = response.ServerEncrypted;
|
||||
ret.EncryptionKeySHA256 = std::move(response.EncryptionKeySHA256);
|
||||
return ret;
|
||||
ret.ETag = std::move(response->ETag);
|
||||
ret.LastModified = std::move(response->LastModified);
|
||||
ret.HttpHeaders = std::move(response->HttpHeaders);
|
||||
ret.Metadata = std::move(response->Metadata);
|
||||
ret.BlobType = response->BlobType;
|
||||
ret.ServerEncrypted = response->ServerEncrypted;
|
||||
ret.EncryptionKeySHA256 = std::move(response->EncryptionKeySHA256);
|
||||
return Azure::Core::Response<BlobDownloadInfo>(
|
||||
std::move(ret),
|
||||
std::make_unique<Azure::Core::Http::RawResponse>(std::move(response.GetRawResponse())));
|
||||
};
|
||||
BlobDownloadInfo ret = returnTypeConverter(firstChunk);
|
||||
auto ret = returnTypeConverter(firstChunk);
|
||||
|
||||
// Keep downloading the remaining in parallel
|
||||
auto downloadChunkFunc
|
||||
@ -237,7 +240,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
auto chunk = Download(chunkOptions);
|
||||
int64_t bytesRead = Azure::Core::Http::BodyStream::ReadToCount(
|
||||
chunkOptions.Context,
|
||||
*chunk.BodyStream,
|
||||
*(chunk->BodyStream),
|
||||
buffer + (offset - firstChunkOffset),
|
||||
chunkOptions.Length.GetValue());
|
||||
if (bytesRead != chunkOptions.Length.GetValue())
|
||||
@ -268,11 +271,11 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
Details::ConcurrentTransfer(
|
||||
remainingOffset, remainingSize, chunkSize, options.Concurrency, downloadChunkFunc);
|
||||
ret.ContentLength = blobRangeSize;
|
||||
ret->ContentLength = blobRangeSize;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BlobDownloadInfo BlobClient::DownloadToFile(
|
||||
Azure::Core::Response<BlobDownloadInfo> BlobClient::DownloadToFile(
|
||||
const std::string& file,
|
||||
const DownloadBlobToFileOptions& options) const
|
||||
{
|
||||
@ -308,8 +311,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
int64_t blobRangeSize;
|
||||
if (firstChunkOptions.Offset.HasValue())
|
||||
{
|
||||
blobSize = std::stoll(firstChunk.ContentRange.GetValue().substr(
|
||||
firstChunk.ContentRange.GetValue().find('/') + 1));
|
||||
blobSize = std::stoll(firstChunk->ContentRange.GetValue().substr(
|
||||
firstChunk->ContentRange.GetValue().find('/') + 1));
|
||||
blobRangeSize = blobSize - firstChunkOffset;
|
||||
if (options.Length.HasValue())
|
||||
{
|
||||
@ -318,7 +321,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
else
|
||||
{
|
||||
blobSize = firstChunk.BodyStream->Length();
|
||||
blobSize = firstChunk->BodyStream->Length();
|
||||
blobRangeSize = blobSize;
|
||||
}
|
||||
firstChunkLength = std::min(firstChunkLength, blobRangeSize);
|
||||
@ -346,21 +349,23 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
};
|
||||
|
||||
bodyStreamToFile(
|
||||
*firstChunk.BodyStream, fileWriter, 0, firstChunkLength, firstChunkOptions.Context);
|
||||
firstChunk.BodyStream.reset();
|
||||
*(firstChunk->BodyStream), fileWriter, 0, firstChunkLength, firstChunkOptions.Context);
|
||||
firstChunk->BodyStream.reset();
|
||||
|
||||
auto returnTypeConverter = [](BlobDownloadResponse& response) {
|
||||
auto returnTypeConverter = [](Azure::Core::Response<BlobDownloadResponse>& response) {
|
||||
BlobDownloadInfo ret;
|
||||
ret.ETag = std::move(response.ETag);
|
||||
ret.LastModified = std::move(response.LastModified);
|
||||
ret.HttpHeaders = std::move(response.HttpHeaders);
|
||||
ret.Metadata = std::move(response.Metadata);
|
||||
ret.BlobType = response.BlobType;
|
||||
ret.ServerEncrypted = response.ServerEncrypted;
|
||||
ret.EncryptionKeySHA256 = std::move(response.EncryptionKeySHA256);
|
||||
return ret;
|
||||
ret.ETag = std::move(response->ETag);
|
||||
ret.LastModified = std::move(response->LastModified);
|
||||
ret.HttpHeaders = std::move(response->HttpHeaders);
|
||||
ret.Metadata = std::move(response->Metadata);
|
||||
ret.BlobType = response->BlobType;
|
||||
ret.ServerEncrypted = response->ServerEncrypted;
|
||||
ret.EncryptionKeySHA256 = std::move(response->EncryptionKeySHA256);
|
||||
return Azure::Core::Response<BlobDownloadInfo>(
|
||||
std::move(ret),
|
||||
std::make_unique<Azure::Core::Http::RawResponse>(std::move(response.GetRawResponse())));
|
||||
};
|
||||
BlobDownloadInfo ret = returnTypeConverter(firstChunk);
|
||||
auto ret = returnTypeConverter(firstChunk);
|
||||
|
||||
// Keep downloading the remaining in parallel
|
||||
auto downloadChunkFunc
|
||||
@ -371,7 +376,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
chunkOptions.Length = length;
|
||||
auto chunk = Download(chunkOptions);
|
||||
bodyStreamToFile(
|
||||
*chunk.BodyStream,
|
||||
*(chunk->BodyStream),
|
||||
fileWriter,
|
||||
offset - firstChunkOffset,
|
||||
chunkOptions.Length.GetValue(),
|
||||
@ -400,11 +405,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
Details::ConcurrentTransfer(
|
||||
remainingOffset, remainingSize, chunkSize, options.Concurrency, downloadChunkFunc);
|
||||
ret.ContentLength = blobRangeSize;
|
||||
ret->ContentLength = blobRangeSize;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BlobProperties BlobClient::GetProperties(const GetBlobPropertiesOptions& options) const
|
||||
Azure::Core::Response<BlobProperties> BlobClient::GetProperties(
|
||||
const GetBlobPropertiesOptions& options) const
|
||||
{
|
||||
BlobRestClient::Blob::GetPropertiesOptions protocolLayerOptions;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
@ -416,7 +422,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
SetBlobHttpHeadersResponse BlobClient::SetHttpHeaders(
|
||||
Azure::Core::Response<BlobInfo> BlobClient::SetHttpHeaders(
|
||||
BlobHttpHeaders httpHeaders,
|
||||
const SetBlobHttpHeadersOptions& options) const
|
||||
{
|
||||
@ -431,7 +437,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
SetBlobMetadataResponse BlobClient::SetMetadata(
|
||||
Azure::Core::Response<BlobInfo> BlobClient::SetMetadata(
|
||||
std::map<std::string, std::string> metadata,
|
||||
const SetBlobMetadataOptions& options) const
|
||||
{
|
||||
@ -446,7 +452,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
SetAccessTierResponse BlobClient::SetAccessTier(
|
||||
Azure::Core::Response<SetAccessTierResponse> BlobClient::SetAccessTier(
|
||||
AccessTier Tier,
|
||||
const SetAccessTierOptions& options) const
|
||||
{
|
||||
@ -457,7 +463,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobCopyInfo BlobClient::StartCopyFromUri(
|
||||
Azure::Core::Response<BlobCopyInfo> BlobClient::StartCopyFromUri(
|
||||
const std::string& sourceUri,
|
||||
const StartCopyFromUriOptions& options) const
|
||||
{
|
||||
@ -480,7 +486,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
AbortCopyBlobResponse BlobClient::AbortCopyFromUri(
|
||||
Azure::Core::Response<AbortCopyBlobResponse> BlobClient::AbortCopyFromUri(
|
||||
const std::string& copyId,
|
||||
const AbortCopyFromUriOptions& options) const
|
||||
{
|
||||
@ -491,7 +497,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobSnapshotInfo BlobClient::CreateSnapshot(const CreateSnapshotOptions& options) const
|
||||
Azure::Core::Response<BlobSnapshotInfo> BlobClient::CreateSnapshot(
|
||||
const CreateSnapshotOptions& options) const
|
||||
{
|
||||
BlobRestClient::Blob::CreateSnapshotOptions protocolLayerOptions;
|
||||
protocolLayerOptions.Metadata = options.Metadata;
|
||||
@ -504,7 +511,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
DeleteBlobResponse BlobClient::Delete(const DeleteBlobOptions& options) const
|
||||
Azure::Core::Response<DeleteBlobResponse> BlobClient::Delete(
|
||||
const DeleteBlobOptions& options) const
|
||||
{
|
||||
BlobRestClient::Blob::DeleteOptions protocolLayerOptions;
|
||||
protocolLayerOptions.DeleteSnapshots = options.DeleteSnapshots;
|
||||
@ -517,7 +525,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
UndeleteBlobResponse BlobClient::Undelete(const UndeleteBlobOptions& options) const
|
||||
Azure::Core::Response<UndeleteBlobResponse> BlobClient::Undelete(
|
||||
const UndeleteBlobOptions& options) const
|
||||
{
|
||||
BlobRestClient::Blob::UndeleteOptions protocolLayerOptions;
|
||||
return BlobRestClient::Blob::Undelete(
|
||||
|
||||
@ -126,7 +126,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return GetBlobClient(blobName).GetPageBlobClient();
|
||||
}
|
||||
|
||||
BlobContainerInfo BlobContainerClient::Create(const CreateBlobContainerOptions& options) const
|
||||
Azure::Core::Response<BlobContainerInfo> BlobContainerClient::Create(
|
||||
const CreateBlobContainerOptions& options) const
|
||||
{
|
||||
BlobRestClient::Container::CreateOptions protocolLayerOptions;
|
||||
protocolLayerOptions.AccessType = options.AccessType;
|
||||
@ -135,7 +136,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
DeleteContainerResponse BlobContainerClient::Delete(
|
||||
Azure::Core::Response<DeleteContainerResponse> BlobContainerClient::Delete(
|
||||
const DeleteBlobContainerOptions& options) const
|
||||
{
|
||||
BlobRestClient::Container::DeleteOptions protocolLayerOptions;
|
||||
@ -146,7 +147,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobContainerProperties BlobContainerClient::GetProperties(
|
||||
Azure::Core::Response<BlobContainerProperties> BlobContainerClient::GetProperties(
|
||||
const GetBlobContainerPropertiesOptions& options) const
|
||||
{
|
||||
BlobRestClient::Container::GetPropertiesOptions protocolLayerOptions;
|
||||
@ -155,7 +156,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
SetContainerMetadataResponse BlobContainerClient::SetMetadata(
|
||||
Azure::Core::Response<BlobContainerInfo> BlobContainerClient::SetMetadata(
|
||||
std::map<std::string, std::string> metadata,
|
||||
SetBlobContainerMetadataOptions options) const
|
||||
{
|
||||
@ -167,7 +168,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobsFlatSegment BlobContainerClient::ListBlobsFlat(const ListBlobsOptions& options) const
|
||||
Azure::Core::Response<BlobsFlatSegment> BlobContainerClient::ListBlobsFlat(
|
||||
const ListBlobsOptions& options) const
|
||||
{
|
||||
BlobRestClient::Container::ListBlobsFlatOptions protocolLayerOptions;
|
||||
protocolLayerOptions.Prefix = options.Prefix;
|
||||
@ -178,7 +180,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobsHierarchySegment BlobContainerClient::ListBlobsByHierarchy(
|
||||
Azure::Core::Response<BlobsHierarchySegment> BlobContainerClient::ListBlobsByHierarchy(
|
||||
const std::string& delimiter,
|
||||
const ListBlobsOptions& options) const
|
||||
{
|
||||
|
||||
@ -107,7 +107,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return BlobContainerClient(std::move(containerUri), m_pipeline);
|
||||
}
|
||||
|
||||
ListContainersSegment BlobServiceClient::ListBlobContainersSegment(
|
||||
Azure::Core::Response<ListContainersSegment> BlobServiceClient::ListBlobContainersSegment(
|
||||
const ListBlobContainersOptions& options) const
|
||||
{
|
||||
BlobRestClient::Service::ListBlobContainersOptions protocolLayerOptions;
|
||||
@ -119,7 +119,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_serviceUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
UserDelegationKey BlobServiceClient::GetUserDelegationKey(
|
||||
Azure::Core::Response<UserDelegationKey> BlobServiceClient::GetUserDelegationKey(
|
||||
const std::string& startsOn,
|
||||
const std::string& expiresOn,
|
||||
const GetUserDelegationKeyOptions& options) const
|
||||
|
||||
@ -61,7 +61,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return newClient;
|
||||
}
|
||||
|
||||
BlobContentInfo BlockBlobClient::Upload(
|
||||
Azure::Core::Response<BlobContentInfo> BlockBlobClient::Upload(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const UploadBlockBlobOptions& options) const
|
||||
{
|
||||
@ -80,7 +80,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), *content, protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobContentInfo BlockBlobClient::UploadFromBuffer(
|
||||
Azure::Core::Response<BlobContentInfo> BlockBlobClient::UploadFromBuffer(
|
||||
const uint8_t* buffer,
|
||||
std::size_t bufferSize,
|
||||
const UploadBlobOptions& options) const
|
||||
@ -133,12 +133,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
commitBlockListOptions.Metadata = options.Metadata;
|
||||
commitBlockListOptions.Tier = options.Tier;
|
||||
auto commitBlockListResponse = CommitBlockList(blockIds, commitBlockListOptions);
|
||||
commitBlockListResponse.ContentCRC64.Reset();
|
||||
commitBlockListResponse.ContentMD5.Reset();
|
||||
commitBlockListResponse->ContentCRC64.Reset();
|
||||
commitBlockListResponse->ContentMD5.Reset();
|
||||
return commitBlockListResponse;
|
||||
}
|
||||
|
||||
BlobContentInfo BlockBlobClient::UploadFromFile(
|
||||
Azure::Core::Response<BlobContentInfo> BlockBlobClient::UploadFromFile(
|
||||
const std::string& file,
|
||||
const UploadBlobOptions& options) const
|
||||
{
|
||||
@ -194,12 +194,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
commitBlockListOptions.Metadata = options.Metadata;
|
||||
commitBlockListOptions.Tier = options.Tier;
|
||||
auto commitBlockListResponse = CommitBlockList(blockIds, commitBlockListOptions);
|
||||
commitBlockListResponse.ContentCRC64.Reset();
|
||||
commitBlockListResponse.ContentMD5.Reset();
|
||||
commitBlockListResponse->ContentCRC64.Reset();
|
||||
commitBlockListResponse->ContentMD5.Reset();
|
||||
return commitBlockListResponse;
|
||||
}
|
||||
|
||||
BlockInfo BlockBlobClient::StageBlock(
|
||||
Azure::Core::Response<BlockInfo> BlockBlobClient::StageBlock(
|
||||
const std::string& blockId,
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const StageBlockOptions& options) const
|
||||
@ -213,7 +213,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), *content, protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlockInfo BlockBlobClient::StageBlockFromUri(
|
||||
Azure::Core::Response<BlockInfo> BlockBlobClient::StageBlockFromUri(
|
||||
const std::string& blockId,
|
||||
const std::string& sourceUri,
|
||||
const StageBlockFromUriOptions& options) const
|
||||
@ -245,7 +245,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobContentInfo BlockBlobClient::CommitBlockList(
|
||||
Azure::Core::Response<BlobContentInfo> BlockBlobClient::CommitBlockList(
|
||||
const std::vector<std::pair<BlockType, std::string>>& blockIds,
|
||||
const CommitBlockListOptions& options) const
|
||||
{
|
||||
@ -263,7 +263,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
BlobBlockListInfo BlockBlobClient::GetBlockList(const GetBlockListOptions& options) const
|
||||
Azure::Core::Response<BlobBlockListInfo> BlockBlobClient::GetBlockList(
|
||||
const GetBlockListOptions& options) const
|
||||
{
|
||||
BlobRestClient::BlockBlob::GetBlockListOptions protocolLayerOptions;
|
||||
protocolLayerOptions.ListType = options.ListType;
|
||||
|
||||
@ -56,7 +56,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return newClient;
|
||||
}
|
||||
|
||||
BlobContentInfo PageBlobClient::Create(
|
||||
Azure::Core::Response<BlobContentInfo> PageBlobClient::Create(
|
||||
int64_t blobContentLength,
|
||||
const CreatePageBlobOptions& options)
|
||||
{
|
||||
@ -75,7 +75,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
PageInfo PageBlobClient::UploadPages(
|
||||
Azure::Core::Response<PageInfo> PageBlobClient::UploadPages(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
int64_t offset,
|
||||
const UploadPagesOptions& options)
|
||||
@ -93,7 +93,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), *content, protocolLayerOptions);
|
||||
}
|
||||
|
||||
PageInfo PageBlobClient::UploadPagesFromUri(
|
||||
Azure::Core::Response<PageInfo> PageBlobClient::UploadPagesFromUri(
|
||||
std::string sourceUri,
|
||||
int64_t sourceOffset,
|
||||
int64_t sourceLength,
|
||||
@ -117,7 +117,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
PageInfo PageBlobClient::ClearPages(
|
||||
Azure::Core::Response<PageInfo> PageBlobClient::ClearPages(
|
||||
int64_t offset,
|
||||
int64_t length,
|
||||
const ClearPagesOptions& options)
|
||||
@ -133,7 +133,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
PageBlobInfo PageBlobClient::Resize(
|
||||
Azure::Core::Response<PageBlobInfo> PageBlobClient::Resize(
|
||||
int64_t blobContentLength,
|
||||
const ResizePageBlobOptions& options)
|
||||
{
|
||||
@ -148,7 +148,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
PageRangesInfo PageBlobClient::GetPageRanges(const GetPageRangesOptions& options)
|
||||
Azure::Core::Response<PageRangesInfo> PageBlobClient::GetPageRanges(
|
||||
const GetPageRangesOptions& options)
|
||||
{
|
||||
BlobRestClient::PageBlob::GetPageRangesOptions protocolLayerOptions;
|
||||
protocolLayerOptions.PreviousSnapshot = options.PreviousSnapshot;
|
||||
@ -167,25 +168,24 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
|
||||
PageRangesInfo ret;
|
||||
ret.RequestId = std::move(protocolLayerResponse.RequestId);
|
||||
ret.Date = std::move(protocolLayerResponse.Date);
|
||||
ret.Version = std::move(protocolLayerResponse.Version);
|
||||
ret.ClientRequestId = std::move(protocolLayerResponse.ClientRequestId);
|
||||
ret.ETag = std::move(protocolLayerResponse.ETag);
|
||||
ret.LastModified = std::move(protocolLayerResponse.LastModified);
|
||||
ret.BlobContentLength = protocolLayerResponse.BlobContentLength;
|
||||
for (const auto& range : protocolLayerResponse.PageRanges)
|
||||
ret.ETag = std::move(protocolLayerResponse->ETag);
|
||||
ret.LastModified = std::move(protocolLayerResponse->LastModified);
|
||||
ret.BlobContentLength = protocolLayerResponse->BlobContentLength;
|
||||
for (const auto& range : protocolLayerResponse->PageRanges)
|
||||
{
|
||||
ret.PageRanges.emplace_back(PageRange{range.first, range.second - range.first + 1});
|
||||
}
|
||||
for (const auto& range : protocolLayerResponse.ClearRanges)
|
||||
for (const auto& range : protocolLayerResponse->ClearRanges)
|
||||
{
|
||||
ret.ClearRanges.emplace_back(PageRange{range.first, range.second - range.first + 1});
|
||||
}
|
||||
return ret;
|
||||
return Azure::Core::Response<PageRangesInfo>(
|
||||
std::move(ret),
|
||||
std::make_unique<Azure::Core::Http::RawResponse>(
|
||||
std::move(protocolLayerResponse.GetRawResponse())));
|
||||
}
|
||||
|
||||
BlobCopyInfo PageBlobClient::StartCopyIncremental(
|
||||
Azure::Core::Response<BlobCopyInfo> PageBlobClient::StartCopyIncremental(
|
||||
const std::string& sourceUri,
|
||||
const IncrementalCopyPageBlobOptions& options)
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
= Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
m_appendBlobClient->AppendBlock(&blockContent);
|
||||
m_blobUploadOptions.HttpHeaders.ContentMD5
|
||||
= m_appendBlobClient->GetProperties().HttpHeaders.ContentMD5;
|
||||
= m_appendBlobClient->GetProperties()->HttpHeaders.ContentMD5;
|
||||
}
|
||||
|
||||
void AppendBlobClientTest::TearDownTestSuite() { BlobContainerClientTest::TearDownTestSuite(); }
|
||||
@ -44,7 +44,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
StandardStorageConnectionString(), m_containerName, RandomString());
|
||||
appendBlobClient.Create(m_blobUploadOptions);
|
||||
|
||||
auto properties = appendBlobClient.GetProperties();
|
||||
auto properties = *appendBlobClient.GetProperties();
|
||||
EXPECT_TRUE(properties.CommittedBlockCount.HasValue());
|
||||
EXPECT_EQ(properties.CommittedBlockCount.GetValue(), 0);
|
||||
EXPECT_EQ(properties.ContentLength, 0);
|
||||
@ -52,7 +52,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto blockContent
|
||||
= Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
appendBlobClient.AppendBlock(&blockContent);
|
||||
properties = appendBlobClient.GetProperties();
|
||||
properties = *appendBlobClient.GetProperties();
|
||||
EXPECT_EQ(properties.CommittedBlockCount.GetValue(), 1);
|
||||
EXPECT_EQ(properties.ContentLength, static_cast<int64_t>(m_blobContent.size()));
|
||||
|
||||
@ -64,7 +64,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
appendBlobClient.AppendBlock(&blockContent, options);
|
||||
|
||||
properties = appendBlobClient.GetProperties();
|
||||
properties = *appendBlobClient.GetProperties();
|
||||
options = Azure::Storage::Blobs::AppendBlockOptions();
|
||||
options.AccessConditions.MaxSize = properties.ContentLength + m_blobContent.size() - 1;
|
||||
blockContent = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
|
||||
@ -32,17 +32,17 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
metadata["key2"] = "TWO";
|
||||
options.Metadata = metadata;
|
||||
auto res = container_client.Create(options);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_THROW(container_client.Create(), std::runtime_error);
|
||||
|
||||
auto res2 = container_client.Delete();
|
||||
EXPECT_FALSE(res2.RequestId.empty());
|
||||
EXPECT_FALSE(res2.Date.empty());
|
||||
EXPECT_FALSE(res2.Version.empty());
|
||||
EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
}
|
||||
|
||||
TEST_F(BlobContainerClientTest, Metadata)
|
||||
@ -51,23 +51,24 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
metadata["key1"] = "one";
|
||||
metadata["key2"] = "TWO";
|
||||
auto res = m_blobContainerClient->SetMetadata(metadata);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
|
||||
auto properties = m_blobContainerClient->GetProperties();
|
||||
EXPECT_FALSE(properties.RequestId.empty());
|
||||
EXPECT_FALSE(properties.Date.empty());
|
||||
auto res2 = m_blobContainerClient->GetProperties();
|
||||
EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res2.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
auto properties = *res2;
|
||||
EXPECT_FALSE(properties.ETag.empty());
|
||||
EXPECT_FALSE(properties.LastModified.empty());
|
||||
EXPECT_FALSE(properties.Version.empty());
|
||||
EXPECT_EQ(properties.Metadata, metadata);
|
||||
|
||||
metadata.clear();
|
||||
m_blobContainerClient->SetMetadata(metadata);
|
||||
properties = m_blobContainerClient->GetProperties();
|
||||
properties = *m_blobContainerClient->GetProperties();
|
||||
EXPECT_TRUE(properties.Metadata.empty());
|
||||
}
|
||||
|
||||
@ -106,15 +107,14 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
do
|
||||
{
|
||||
auto res = m_blobContainerClient->ListBlobsFlat(options);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
;
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ServiceEndpoint.empty());
|
||||
EXPECT_EQ(res.Container, m_containerName);
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ServiceEndpoint.empty());
|
||||
EXPECT_EQ(res->Container, m_containerName);
|
||||
|
||||
options.Marker = res.NextMarker;
|
||||
for (const auto& blob : res.Items)
|
||||
options.Marker = res->NextMarker;
|
||||
for (const auto& blob : res->Items)
|
||||
{
|
||||
EXPECT_FALSE(blob.Name.empty());
|
||||
EXPECT_FALSE(blob.CreationTime.empty());
|
||||
@ -133,8 +133,8 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
do
|
||||
{
|
||||
auto res = m_blobContainerClient->ListBlobsFlat(options);
|
||||
options.Marker = res.NextMarker;
|
||||
for (const auto& blob : res.Items)
|
||||
options.Marker = res->NextMarker;
|
||||
for (const auto& blob : res->Items)
|
||||
{
|
||||
listBlobs.insert(blob.Name);
|
||||
}
|
||||
@ -167,16 +167,16 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
while (true)
|
||||
{
|
||||
auto res = m_blobContainerClient->ListBlobsByHierarchy(delimiter, options);
|
||||
EXPECT_EQ(res.Delimiter, delimiter);
|
||||
EXPECT_EQ(res.Prefix, options.Prefix.GetValue());
|
||||
EXPECT_TRUE(res.Items.empty());
|
||||
for (const auto& i : res.BlobPrefixes)
|
||||
EXPECT_EQ(res->Delimiter, delimiter);
|
||||
EXPECT_EQ(res->Prefix, options.Prefix.GetValue());
|
||||
EXPECT_TRUE(res->Items.empty());
|
||||
for (const auto& i : res->BlobPrefixes)
|
||||
{
|
||||
items.emplace(i.Name);
|
||||
}
|
||||
if (!res.NextMarker.empty())
|
||||
if (!res->NextMarker.empty())
|
||||
{
|
||||
options.Marker = res.NextMarker;
|
||||
options.Marker = res->NextMarker;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -192,16 +192,16 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
while (true)
|
||||
{
|
||||
auto res = m_blobContainerClient->ListBlobsByHierarchy(delimiter, options);
|
||||
EXPECT_EQ(res.Delimiter, delimiter);
|
||||
EXPECT_EQ(res.Prefix, options.Prefix.GetValue());
|
||||
EXPECT_TRUE(res.BlobPrefixes.empty());
|
||||
for (const auto& i : res.Items)
|
||||
EXPECT_EQ(res->Delimiter, delimiter);
|
||||
EXPECT_EQ(res->Prefix, options.Prefix.GetValue());
|
||||
EXPECT_TRUE(res->BlobPrefixes.empty());
|
||||
for (const auto& i : res->Items)
|
||||
{
|
||||
items.emplace(i.Name);
|
||||
}
|
||||
if (!res.NextMarker.empty())
|
||||
if (!res->NextMarker.empty())
|
||||
{
|
||||
options.Marker = res.NextMarker;
|
||||
options.Marker = res->NextMarker;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -49,13 +49,13 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
do
|
||||
{
|
||||
auto res = m_blobServiceClient.ListBlobContainersSegment(options);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ServiceEndpoint.empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ServiceEndpoint.empty());
|
||||
|
||||
options.Marker = res.NextMarker;
|
||||
for (const auto& container : res.Items)
|
||||
options.Marker = res->NextMarker;
|
||||
for (const auto& container : res->Items)
|
||||
{
|
||||
listContainers.insert(container.Name);
|
||||
}
|
||||
@ -71,13 +71,13 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
do
|
||||
{
|
||||
auto res = m_blobServiceClient.ListBlobContainersSegment(options);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ServiceEndpoint.empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ServiceEndpoint.empty());
|
||||
|
||||
options.Marker = res.NextMarker;
|
||||
for (const auto& container : res.Items)
|
||||
options.Marker = res->NextMarker;
|
||||
for (const auto& container : res->Items)
|
||||
{
|
||||
EXPECT_FALSE(container.Name.empty());
|
||||
EXPECT_FALSE(container.ETag.empty());
|
||||
|
||||
@ -53,7 +53,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
= Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
m_blockBlobClient->Upload(&blobContent, m_blobUploadOptions);
|
||||
m_blobUploadOptions.HttpHeaders.ContentMD5
|
||||
= m_blockBlobClient->GetProperties().HttpHeaders.ContentMD5;
|
||||
= m_blockBlobClient->GetProperties()->HttpHeaders.ContentMD5;
|
||||
}
|
||||
|
||||
void BlockBlobClientTest::TearDownTestSuite() { BlobContainerClientTest::TearDownTestSuite(); }
|
||||
@ -76,26 +76,26 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
TEST_F(BlockBlobClientTest, UploadDownload)
|
||||
{
|
||||
auto res = m_blockBlobClient->Download();
|
||||
EXPECT_EQ(ReadBodyStream(res.BodyStream), m_blobContent);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(ReadBodyStream(res->BodyStream), m_blobContent);
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
Azure::Storage::Blobs::DownloadBlobOptions options;
|
||||
options.Offset = 1_MB;
|
||||
options.Length = 2_MB;
|
||||
res = m_blockBlobClient->Download(options);
|
||||
EXPECT_EQ(
|
||||
ReadBodyStream(res.BodyStream),
|
||||
ReadBodyStream(res->BodyStream),
|
||||
std::vector<uint8_t>(
|
||||
m_blobContent.begin() + static_cast<std::size_t>(options.Offset.GetValue()),
|
||||
m_blobContent.begin()
|
||||
+ static_cast<std::size_t>(options.Offset.GetValue() + options.Length.GetValue())));
|
||||
EXPECT_FALSE(res.ContentRange.GetValue().empty());
|
||||
EXPECT_FALSE(res->ContentRange.GetValue().empty());
|
||||
}
|
||||
|
||||
TEST_F(BlockBlobClientTest, DownloadEmpty)
|
||||
@ -110,15 +110,15 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
blockBlobClient.SetMetadata(m_blobUploadOptions.Metadata);
|
||||
|
||||
auto res = blockBlobClient.Download();
|
||||
EXPECT_EQ(res.BodyStream->Length(), 0);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(res->BodyStream->Length(), 0);
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
|
||||
Azure::Storage::Blobs::DownloadBlobOptions options;
|
||||
options.Offset = 0;
|
||||
@ -132,17 +132,17 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto blobClient = m_blobContainerClient->GetBlobClient(RandomString());
|
||||
auto res = blobClient.StartCopyFromUri(m_blockBlobClient->GetUri());
|
||||
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_FALSE(res.CopyId.empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_FALSE(res->CopyId.empty());
|
||||
EXPECT_TRUE(
|
||||
res.CopyStatus == Azure::Storage::Blobs::CopyStatus::Pending
|
||||
|| res.CopyStatus == Azure::Storage::Blobs::CopyStatus::Success);
|
||||
auto properties = blobClient.GetProperties();
|
||||
EXPECT_EQ(properties.CopyId.GetValue(), res.CopyId);
|
||||
res->CopyStatus == Azure::Storage::Blobs::CopyStatus::Pending
|
||||
|| res->CopyStatus == Azure::Storage::Blobs::CopyStatus::Success);
|
||||
auto properties = *blobClient.GetProperties();
|
||||
EXPECT_EQ(properties.CopyId.GetValue(), res->CopyId);
|
||||
EXPECT_FALSE(properties.CopySource.GetValue().empty());
|
||||
EXPECT_TRUE(
|
||||
properties.CopyStatus.GetValue() == Azure::Storage::Blobs::CopyStatus::Pending
|
||||
@ -157,15 +157,15 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
TEST_F(BlockBlobClientTest, SnapShot)
|
||||
{
|
||||
auto res = m_blockBlobClient->CreateSnapshot();
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_FALSE(res.Snapshot.empty());
|
||||
auto snapshotClient = m_blockBlobClient->WithSnapshot(res.Snapshot);
|
||||
EXPECT_EQ(ReadBodyStream(snapshotClient.Download().BodyStream), m_blobContent);
|
||||
EXPECT_EQ(snapshotClient.GetProperties().Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_FALSE(res->Snapshot.empty());
|
||||
auto snapshotClient = m_blockBlobClient->WithSnapshot(res->Snapshot);
|
||||
EXPECT_EQ(ReadBodyStream(snapshotClient.Download()->BodyStream), m_blobContent);
|
||||
EXPECT_EQ(snapshotClient.GetProperties()->Metadata, m_blobUploadOptions.Metadata);
|
||||
auto emptyContent = Azure::Core::Http::MemoryBodyStream(nullptr, 0);
|
||||
EXPECT_THROW(snapshotClient.Upload(&emptyContent), std::runtime_error);
|
||||
EXPECT_THROW(snapshotClient.SetMetadata({}), std::runtime_error);
|
||||
@ -178,9 +178,9 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Azure::Storage::Blobs::CreateSnapshotOptions options;
|
||||
options.Metadata = {{"snapshotkey1", "snapshotvalue1"}, {"snapshotkey2", "SNAPSHOTVALUE2"}};
|
||||
res = m_blockBlobClient->CreateSnapshot(options);
|
||||
EXPECT_FALSE(res.Snapshot.empty());
|
||||
snapshotClient = m_blockBlobClient->WithSnapshot(res.Snapshot);
|
||||
EXPECT_EQ(snapshotClient.GetProperties().Metadata, options.Metadata);
|
||||
EXPECT_FALSE(res->Snapshot.empty());
|
||||
snapshotClient = m_blockBlobClient->WithSnapshot(res->Snapshot);
|
||||
EXPECT_EQ(snapshotClient.GetProperties()->Metadata, options.Metadata);
|
||||
}
|
||||
|
||||
TEST_F(BlockBlobClientTest, Properties)
|
||||
@ -195,17 +195,17 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
blockBlobClient.SetHttpHeaders(m_blobUploadOptions.HttpHeaders);
|
||||
|
||||
auto res = blockBlobClient.GetProperties();
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_FALSE(res.CreationTime.empty());
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.ContentLength, static_cast<int64_t>(m_blobContent.size()));
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Tier.GetValue(), Azure::Storage::Blobs::AccessTier::Cool);
|
||||
EXPECT_FALSE(res.AccessTierChangeTime.GetValue().empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_FALSE(res->CreationTime.empty());
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->ContentLength, static_cast<int64_t>(m_blobContent.size()));
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Tier.GetValue(), Azure::Storage::Blobs::AccessTier::Cool);
|
||||
EXPECT_FALSE(res->AccessTierChangeTime.GetValue().empty());
|
||||
}
|
||||
|
||||
TEST_F(BlockBlobClientTest, StageBlock)
|
||||
@ -226,16 +226,16 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
blockBlobClient.CommitBlockList(
|
||||
{{Azure::Storage::Blobs::BlockType::Uncommitted, blockId1}}, options);
|
||||
auto res = blockBlobClient.GetBlockList();
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.ContentLength, static_cast<int64_t>(block1Content.size()));
|
||||
ASSERT_FALSE(res.CommittedBlocks.empty());
|
||||
EXPECT_EQ(res.CommittedBlocks[0].Name, blockId1);
|
||||
EXPECT_EQ(res.CommittedBlocks[0].Size, static_cast<int64_t>(block1Content.size()));
|
||||
EXPECT_TRUE(res.UncommittedBlocks.empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderRequestId).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderDate).empty());
|
||||
EXPECT_FALSE(res.GetRawResponse().GetHeaders().at(Details::c_HttpHeaderXMsVersion).empty());
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->ContentLength, static_cast<int64_t>(block1Content.size()));
|
||||
ASSERT_FALSE(res->CommittedBlocks.empty());
|
||||
EXPECT_EQ(res->CommittedBlocks[0].Name, blockId1);
|
||||
EXPECT_EQ(res->CommittedBlocks[0].Size, static_cast<int64_t>(block1Content.size()));
|
||||
EXPECT_TRUE(res->UncommittedBlocks.empty());
|
||||
|
||||
// TODO: StageBlockFromUri must be authorized with SAS, but we don't have SAS for now.
|
||||
/*
|
||||
@ -268,11 +268,11 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
downloadBuffer.assign(downloadBuffer.size(), '\x00');
|
||||
auto res = m_blockBlobClient->DownloadToBuffer(downloadBuffer.data(), downloadBuffer.size());
|
||||
EXPECT_EQ(downloadBuffer, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadBuffer.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadBuffer.size());
|
||||
res = m_blockBlobClient->DownloadToFile(tempFilename);
|
||||
auto downloadFile = ReadFile(tempFilename);
|
||||
EXPECT_EQ(downloadFile, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadFile.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadFile.size());
|
||||
DeleteFile(tempFilename);
|
||||
|
||||
// download whole blob
|
||||
@ -280,11 +280,11 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.Offset = 0;
|
||||
res = m_blockBlobClient->DownloadToBuffer(downloadBuffer.data(), downloadBuffer.size());
|
||||
EXPECT_EQ(downloadBuffer, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadBuffer.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadBuffer.size());
|
||||
res = m_blockBlobClient->DownloadToFile(tempFilename);
|
||||
downloadFile = ReadFile(tempFilename);
|
||||
EXPECT_EQ(downloadFile, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadFile.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadFile.size());
|
||||
DeleteFile(tempFilename);
|
||||
|
||||
// download whole blob
|
||||
@ -293,11 +293,11 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.Length = downloadBuffer.size();
|
||||
res = m_blockBlobClient->DownloadToBuffer(downloadBuffer.data(), downloadBuffer.size());
|
||||
EXPECT_EQ(downloadBuffer, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadBuffer.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadBuffer.size());
|
||||
res = m_blockBlobClient->DownloadToFile(tempFilename);
|
||||
downloadFile = ReadFile(tempFilename);
|
||||
EXPECT_EQ(downloadFile, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadFile.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadFile.size());
|
||||
DeleteFile(tempFilename);
|
||||
|
||||
// download whole blob
|
||||
@ -306,11 +306,11 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.Length = downloadBuffer.size() * 2;
|
||||
res = m_blockBlobClient->DownloadToBuffer(downloadBuffer.data(), downloadBuffer.size() * 2);
|
||||
EXPECT_EQ(downloadBuffer, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadBuffer.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadBuffer.size());
|
||||
res = m_blockBlobClient->DownloadToFile(tempFilename);
|
||||
downloadFile = ReadFile(tempFilename);
|
||||
EXPECT_EQ(downloadFile, m_blobContent);
|
||||
EXPECT_EQ(static_cast<std::size_t>(res.ContentLength), downloadFile.size());
|
||||
EXPECT_EQ(static_cast<std::size_t>(res->ContentLength), downloadFile.size());
|
||||
DeleteFile(tempFilename);
|
||||
|
||||
options.InitialChunkSize = 4_KB;
|
||||
@ -334,7 +334,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
m_blobContent.begin() + static_cast<std::size_t>(offset),
|
||||
m_blobContent.begin() + static_cast<std::size_t>(offset)
|
||||
+ static_cast<std::size_t>(actualLength)));
|
||||
EXPECT_EQ(res.ContentLength, actualLength);
|
||||
EXPECT_EQ(res->ContentLength, actualLength);
|
||||
|
||||
std::string tempFilename2 = RandomString();
|
||||
res = m_blockBlobClient->DownloadToFile(tempFilename2, optionsCopy);
|
||||
@ -345,7 +345,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
m_blobContent.begin() + static_cast<std::size_t>(offset),
|
||||
m_blobContent.begin() + static_cast<std::size_t>(offset)
|
||||
+ static_cast<std::size_t>(actualLength)));
|
||||
EXPECT_EQ(res.ContentLength, actualLength);
|
||||
EXPECT_EQ(res->ContentLength, actualLength);
|
||||
DeleteFile(tempFilename2);
|
||||
}
|
||||
else
|
||||
@ -414,36 +414,36 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
blockBlobClient.SetMetadata(m_blobUploadOptions.Metadata);
|
||||
|
||||
auto res = blockBlobClient.DownloadToBuffer(emptyContent.data(), 0);
|
||||
EXPECT_EQ(res.ContentLength, 0);
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(res->ContentLength, 0);
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
res = blockBlobClient.DownloadToFile(tempFilename);
|
||||
EXPECT_EQ(res.ContentLength, 0);
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(res->ContentLength, 0);
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_TRUE(ReadFile(tempFilename).empty());
|
||||
DeleteFile(tempFilename);
|
||||
|
||||
res = blockBlobClient.DownloadToBuffer(emptyContent.data(), static_cast<std::size_t>(8_MB));
|
||||
EXPECT_EQ(res.ContentLength, 0);
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(res->ContentLength, 0);
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
res = blockBlobClient.DownloadToFile(tempFilename);
|
||||
EXPECT_EQ(res.ContentLength, 0);
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(res->ContentLength, 0);
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_TRUE(ReadFile(tempFilename).empty());
|
||||
DeleteFile(tempFilename);
|
||||
|
||||
@ -456,19 +456,19 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
res = blockBlobClient.DownloadToBuffer(
|
||||
emptyContent.data(), static_cast<std::size_t>(8_MB), options);
|
||||
EXPECT_EQ(res.ContentLength, 0);
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(res->ContentLength, 0);
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
res = blockBlobClient.DownloadToFile(tempFilename, options);
|
||||
EXPECT_EQ(res.ContentLength, 0);
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_EQ(res.HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res.Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res.BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_EQ(res->ContentLength, 0);
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_EQ(res->HttpHeaders, m_blobUploadOptions.HttpHeaders);
|
||||
EXPECT_EQ(res->Metadata, m_blobUploadOptions.Metadata);
|
||||
EXPECT_EQ(res->BlobType, Azure::Storage::Blobs::BlobType::BlockBlob);
|
||||
EXPECT_TRUE(ReadFile(tempFilename).empty());
|
||||
DeleteFile(tempFilename);
|
||||
|
||||
@ -525,21 +525,18 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
auto res = blockBlobClient.UploadFromBuffer(
|
||||
m_blobContent.data(), static_cast<std::size_t>(length), options);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_FALSE(res.SequenceNumber.HasValue());
|
||||
EXPECT_FALSE(res.ContentCRC64.HasValue());
|
||||
EXPECT_FALSE(res.ContentMD5.HasValue());
|
||||
auto properties = blockBlobClient.GetProperties();
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_FALSE(res->SequenceNumber.HasValue());
|
||||
EXPECT_FALSE(res->ContentCRC64.HasValue());
|
||||
EXPECT_FALSE(res->ContentMD5.HasValue());
|
||||
auto properties = *blockBlobClient.GetProperties();
|
||||
EXPECT_EQ(properties.ContentLength, length);
|
||||
EXPECT_EQ(properties.HttpHeaders, options.HttpHeaders);
|
||||
EXPECT_EQ(properties.Metadata, options.Metadata);
|
||||
EXPECT_EQ(properties.Tier.GetValue(), options.Tier.GetValue());
|
||||
EXPECT_EQ(properties.ETag, res.ETag);
|
||||
EXPECT_EQ(properties.LastModified, res.LastModified);
|
||||
EXPECT_EQ(properties.ETag, res->ETag);
|
||||
EXPECT_EQ(properties.LastModified, res->LastModified);
|
||||
std::vector<uint8_t> downloadContent(static_cast<std::size_t>(length), '\x00');
|
||||
blockBlobClient.DownloadToBuffer(
|
||||
downloadContent.data(), static_cast<std::size_t>(length));
|
||||
@ -554,21 +551,18 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
fileWriter.Write(m_blobContent.data(), length, 0);
|
||||
}
|
||||
auto res = blockBlobClient.UploadFromFile(tempFilename, options);
|
||||
EXPECT_FALSE(res.RequestId.empty());
|
||||
EXPECT_FALSE(res.Version.empty());
|
||||
EXPECT_FALSE(res.Date.empty());
|
||||
EXPECT_FALSE(res.ETag.empty());
|
||||
EXPECT_FALSE(res.LastModified.empty());
|
||||
EXPECT_FALSE(res.SequenceNumber.HasValue());
|
||||
EXPECT_FALSE(res.ContentCRC64.HasValue());
|
||||
EXPECT_FALSE(res.ContentMD5.HasValue());
|
||||
auto properties = blockBlobClient.GetProperties();
|
||||
EXPECT_FALSE(res->ETag.empty());
|
||||
EXPECT_FALSE(res->LastModified.empty());
|
||||
EXPECT_FALSE(res->SequenceNumber.HasValue());
|
||||
EXPECT_FALSE(res->ContentCRC64.HasValue());
|
||||
EXPECT_FALSE(res->ContentMD5.HasValue());
|
||||
auto properties = *blockBlobClient.GetProperties();
|
||||
EXPECT_EQ(properties.ContentLength, length);
|
||||
EXPECT_EQ(properties.HttpHeaders, options.HttpHeaders);
|
||||
EXPECT_EQ(properties.Metadata, options.Metadata);
|
||||
EXPECT_EQ(properties.Tier.GetValue(), options.Tier.GetValue());
|
||||
EXPECT_EQ(properties.ETag, res.ETag);
|
||||
EXPECT_EQ(properties.LastModified, res.LastModified);
|
||||
EXPECT_EQ(properties.ETag, res->ETag);
|
||||
EXPECT_EQ(properties.LastModified, res->LastModified);
|
||||
std::vector<uint8_t> downloadContent(static_cast<std::size_t>(length), '\x00');
|
||||
blockBlobClient.DownloadToBuffer(
|
||||
downloadContent.data(), static_cast<std::size_t>(length));
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
= Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
m_pageBlobClient->UploadPages(&pageContent, 0);
|
||||
m_blobUploadOptions.HttpHeaders.ContentMD5
|
||||
= m_pageBlobClient->GetProperties().HttpHeaders.ContentMD5;
|
||||
= m_pageBlobClient->GetProperties()->HttpHeaders.ContentMD5;
|
||||
}
|
||||
|
||||
void PageBlobClientTest::TearDownTestSuite() { BlobContainerClientTest::TearDownTestSuite(); }
|
||||
@ -54,11 +54,11 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
StandardStorageConnectionString(), m_containerName, RandomString());
|
||||
pageBlobClient.Create(0, m_blobUploadOptions);
|
||||
|
||||
EXPECT_EQ(pageBlobClient.GetProperties().ContentLength, 0);
|
||||
EXPECT_EQ(pageBlobClient.GetProperties()->ContentLength, 0);
|
||||
pageBlobClient.Resize(static_cast<int64_t>(2_KB));
|
||||
EXPECT_EQ(static_cast<uint64_t>(pageBlobClient.GetProperties().ContentLength), 2_KB);
|
||||
EXPECT_EQ(static_cast<uint64_t>(pageBlobClient.GetProperties()->ContentLength), 2_KB);
|
||||
pageBlobClient.Resize(static_cast<int64_t>(1_KB));
|
||||
EXPECT_EQ(static_cast<uint64_t>(pageBlobClient.GetProperties().ContentLength), 1_KB);
|
||||
EXPECT_EQ(static_cast<uint64_t>(pageBlobClient.GetProperties()->ContentLength), 1_KB);
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, UploadClear)
|
||||
@ -83,9 +83,9 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
'\x00');
|
||||
|
||||
auto downloadContent = pageBlobClient.Download();
|
||||
EXPECT_EQ(ReadBodyStream(downloadContent.BodyStream), blobContent);
|
||||
EXPECT_EQ(ReadBodyStream(downloadContent->BodyStream), blobContent);
|
||||
|
||||
auto pageRanges = pageBlobClient.GetPageRanges();
|
||||
auto pageRanges = *pageBlobClient.GetPageRanges();
|
||||
EXPECT_TRUE(pageRanges.ClearRanges.empty());
|
||||
ASSERT_FALSE(pageRanges.PageRanges.empty());
|
||||
EXPECT_EQ(static_cast<uint64_t>(pageRanges.PageRanges[0].Offset), 3_KB);
|
||||
@ -94,13 +94,13 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Azure::Storage::Blobs::GetPageRangesOptions options;
|
||||
options.Offset = 4_KB;
|
||||
options.Length = 1_KB;
|
||||
pageRanges = pageBlobClient.GetPageRanges(options);
|
||||
pageRanges = *pageBlobClient.GetPageRanges(options);
|
||||
EXPECT_TRUE(pageRanges.ClearRanges.empty());
|
||||
ASSERT_FALSE(pageRanges.PageRanges.empty());
|
||||
EXPECT_EQ(static_cast<uint64_t>(pageRanges.PageRanges[0].Offset), 4_KB);
|
||||
EXPECT_EQ(static_cast<uint64_t>(pageRanges.PageRanges[0].Length), 1_KB);
|
||||
|
||||
auto snapshot = pageBlobClient.CreateSnapshot().Snapshot;
|
||||
auto snapshot = pageBlobClient.CreateSnapshot()->Snapshot;
|
||||
// |_|_|_|x| |x|x|_|_| This is what's in snapshot
|
||||
blobContent.resize(static_cast<std::size_t>(1_KB));
|
||||
auto pageClient = Azure::Core::Http::MemoryBodyStream(blobContent.data(), blobContent.size());
|
||||
@ -110,7 +110,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
options = Azure::Storage::Blobs::GetPageRangesOptions();
|
||||
options.PreviousSnapshot = snapshot;
|
||||
pageRanges = pageBlobClient.GetPageRanges(options);
|
||||
pageRanges = *pageBlobClient.GetPageRanges(options);
|
||||
ASSERT_FALSE(pageRanges.ClearRanges.empty());
|
||||
ASSERT_FALSE(pageRanges.PageRanges.empty());
|
||||
EXPECT_EQ(pageRanges.PageRanges[0].Offset, 0);
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
|
||||
#include "http/body_stream.hpp"
|
||||
|
||||
#include "common/constants.hpp"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user