Resolve review comments (#545)
* Rename UndeleteContainer->Undelete * Remove concurrent upload page blob * move offset to the first parameter * Rename: TransactionalMd5 TransactionalCrc64 * add batch protocol layer fix x-ms-server-encrypted transactional-md5 * transcational md5 * Remove Transactional headers from ClearPagesResult * parse x-ms-blob-content-md5 * Remove redundant space
This commit is contained in:
parent
62dd39c1be
commit
66c331e52b
@ -149,14 +149,15 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const DeleteContainerOptions& options = DeleteContainerOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Restores a previously deleted container.
|
||||
* @brief Restores a previously deleted container. The destionation is referenced by current
|
||||
* BlobContainerClient.
|
||||
*
|
||||
* @param deletedContainerName The name of the previously deleted container.
|
||||
* @param deletedContainerVersion The version of the previously deleted container.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return An UndeleteContainerResult if successful.
|
||||
*/
|
||||
Azure::Core::Response<UndeleteContainerResult> UndeleteContainer(
|
||||
Azure::Core::Response<UndeleteContainerResult> Undelete(
|
||||
const std::string& deletedContainerName,
|
||||
const std::string& deletedContainerVersion,
|
||||
const UndeleteContainerOptions& options = UndeleteContainerOptions()) const;
|
||||
|
||||
@ -854,14 +854,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
|
||||
/**
|
||||
* @brief A CRC64 hash of the blob content. This hash is used to verify the integrity of
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
|
||||
/**
|
||||
* @brief The standard HTTP header system properties to set.
|
||||
@ -920,8 +920,6 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
int Concurrency = 1;
|
||||
};
|
||||
|
||||
using UploadPageBlobFromOptions = UploadBlockBlobFromOptions;
|
||||
|
||||
/**
|
||||
* @brief Optional parameters for BlockBlobClient::StageBlock.
|
||||
*/
|
||||
@ -937,14 +935,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
|
||||
/**
|
||||
* @brief A CRC64 hash of the blob content. This hash is used to verify the integrity of
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
|
||||
/**
|
||||
* @brief Optional conditions that must be met to perform this operation.
|
||||
@ -978,14 +976,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
|
||||
/**
|
||||
* @brief A CRC64 hash of the blob content. This hash is used to verify the integrity of
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
|
||||
/**
|
||||
* @brief Optional conditions that must be met to perform this operation.
|
||||
@ -1092,14 +1090,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
|
||||
/**
|
||||
* @brief A CRC64 hash of the blob content. This hash is used to verify the integrity of
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
|
||||
/**
|
||||
* @brief Optional conditions that must be met to perform this operation.
|
||||
@ -1133,14 +1131,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
|
||||
/**
|
||||
* @brief A CRC64 hash of the blob content. This hash is used to verify the integrity of
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
|
||||
/**
|
||||
* @brief Optional conditions that must be met to perform this operation.
|
||||
@ -1216,14 +1214,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
|
||||
/**
|
||||
* @brief A CRC64 hash of the blob content. This hash is used to verify the integrity of
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
|
||||
/**
|
||||
* @brief Optional conditions that must be met to perform this operation.
|
||||
@ -1246,14 +1244,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
|
||||
/**
|
||||
* @brief A CRC64 hash of the blob content. This hash is used to verify the integrity of
|
||||
* the blob during transport. When this header is specified, the storage service checks the hash
|
||||
* that has arrived with the one that was sent.
|
||||
*/
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
|
||||
/**
|
||||
* @brief Optional conditions that must be met to perform this operation.
|
||||
|
||||
@ -27,13 +27,6 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
using UploadBlockBlobFromResult = UploadBlockBlobResult;
|
||||
|
||||
struct UploadPageBlobFromResult
|
||||
{
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
Azure::Core::Nullable<std::string> EncryptionScope;
|
||||
};
|
||||
|
||||
struct PageRange
|
||||
{
|
||||
int64_t Offset;
|
||||
|
||||
@ -125,22 +125,25 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
/**
|
||||
* @brief Writes content to a range of pages in a page blob, starting at offset.
|
||||
*
|
||||
* @param content A BodyStream containing the content of the pages to upload.
|
||||
* @param offset Specifies the starting offset for the content to be written as a page. Given
|
||||
* that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of
|
||||
* 512.
|
||||
* @param content A BodyStream containing the content of the pages to upload.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A UploadPageBlobPagesResult describing the state of the updated pages.
|
||||
*/
|
||||
Azure::Core::Response<UploadPageBlobPagesResult> UploadPages(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
int64_t offset,
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const UploadPageBlobPagesOptions& options = UploadPageBlobPagesOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Writes a range of pages to a page blob where the contents are read from a
|
||||
* uri.
|
||||
*
|
||||
* @param destinationOffset Specifies the starting offset for the content to be written. Given
|
||||
* that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of
|
||||
* 512.
|
||||
* @param sourceUri Specifies the uri of the source blob. The value may be a
|
||||
* uri of up to 2 KB in length that specifies a blob. The source blob must either be public or
|
||||
* must be authenticated via a shared access signature. If the source blob is public, no
|
||||
@ -149,46 +152,17 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* offset. This offset doesn't need to be a modulus of 512.
|
||||
* @param sourceLength Only upload specified length of the blob in the sourceUri. This length
|
||||
* must be a modulus of 512.
|
||||
* @param destinationOffset Specifies the starting offset for the content to be written. Given
|
||||
* that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of
|
||||
* 512.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A UploadPageBlobPagesFromUriResult describing the state of the updated pages.
|
||||
*/
|
||||
Azure::Core::Response<UploadPageBlobPagesFromUriResult> UploadPagesFromUri(
|
||||
int64_t destinationoffset,
|
||||
std::string sourceUri,
|
||||
int64_t sourceOffset,
|
||||
int64_t sourceLength,
|
||||
int64_t destinationoffset,
|
||||
const UploadPageBlobPagesFromUriOptions& options
|
||||
= UploadPageBlobPagesFromUriOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Creates a new page blob, or updates the content of an existing page blob. Updating
|
||||
* an existing page blob overwrites any existing metadata on the blob.
|
||||
*
|
||||
* @param buffer A memory buffer containing the content to upload.
|
||||
* @param bufferSize Size of the memory buffer.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A UploadPageBlobPagesResult describing the state of the updated page blob.
|
||||
*/
|
||||
Azure::Core::Response<UploadPageBlobFromResult> UploadFrom(
|
||||
const uint8_t* buffer,
|
||||
std::size_t bufferSize,
|
||||
const UploadPageBlobFromOptions& options = UploadPageBlobFromOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Creates a new page blob, or updates the content of an existing page blob. Updating
|
||||
* an existing page blob overwrites any existing metadata on the blob.
|
||||
*
|
||||
* @param file A file containing the content to upload.
|
||||
* @param options Optional parameters to execute this function.
|
||||
* @return A UploadPageBlobFromResult describing the state of the updated page blob.
|
||||
*/
|
||||
Azure::Core::Response<UploadPageBlobFromResult> UploadFrom(
|
||||
const std::string& file,
|
||||
const UploadPageBlobFromOptions& options = UploadPageBlobFromOptions()) const;
|
||||
|
||||
/**
|
||||
* @brief Clears one or more pages from the page blob, as specificed by offset and length.
|
||||
*
|
||||
|
||||
@ -251,8 +251,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
std::string ETag;
|
||||
std::string LastModified;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
int64_t AppendOffset = 0;
|
||||
int64_t CommittedBlockCount = 0;
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
@ -264,8 +264,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
std::string ETag;
|
||||
std::string LastModified;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
int64_t AppendOffset = 0;
|
||||
int64_t CommittedBlockCount = 0;
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
@ -656,8 +656,6 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
std::string ETag;
|
||||
std::string LastModified;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
int64_t SequenceNumber = 0;
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
@ -672,8 +670,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
Azure::Core::Nullable<std::string> EncryptionScope;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
}; // struct CommitBlockListResult
|
||||
|
||||
enum class CopyStatus
|
||||
@ -1270,8 +1268,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
struct StageBlockFromUriResult
|
||||
{
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
Azure::Core::Nullable<std::string> EncryptionScope;
|
||||
@ -1279,13 +1277,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
struct StageBlockResult
|
||||
{
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
Azure::Core::Nullable<std::string> EncryptionScope;
|
||||
}; // struct StageBlockResult
|
||||
|
||||
struct SubmitBlobBatchResultInternal
|
||||
{
|
||||
std::string ContentType;
|
||||
}; // struct SubmitBlobBatchResultInternal
|
||||
|
||||
struct UndeleteBlobResult
|
||||
{
|
||||
}; // struct UndeleteBlobResult
|
||||
@ -1302,16 +1305,16 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
Azure::Core::Nullable<std::string> EncryptionScope;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
}; // struct UploadBlockBlobResult
|
||||
|
||||
struct UploadPageBlobPagesFromUriResult
|
||||
{
|
||||
std::string ETag;
|
||||
std::string LastModified;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
int64_t SequenceNumber = 0;
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
@ -1322,8 +1325,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
std::string ETag;
|
||||
std::string LastModified;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
int64_t SequenceNumber = 0;
|
||||
Azure::Core::Nullable<bool> ServerEncrypted;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
@ -1518,8 +1521,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Nullable<int64_t> CommittedBlockCount; // only for append blob
|
||||
Azure::Core::Nullable<bool> IsSealed; // only for append blob
|
||||
Blobs::BlobType BlobType = Blobs::BlobType::Unknown;
|
||||
Azure::Core::Nullable<std::string> ContentMd5; // Md5 for the downloaded range
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5; // Md5 for the downloaded range
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<std::string> LeaseDuration;
|
||||
Azure::Core::Nullable<BlobLeaseState> LeaseState;
|
||||
Azure::Core::Nullable<BlobLeaseStatus> LeaseStatus;
|
||||
@ -4893,15 +4896,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
response.BodyStream = httpResponse.GetBodyStream();
|
||||
response.ETag = httpResponse.GetHeaders().at("etag");
|
||||
response.LastModified = httpResponse.GetHeaders().at("last-modified");
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
auto response_http_headers_content_type_iterator
|
||||
= httpResponse.GetHeaders().find("content-type");
|
||||
@ -4935,6 +4941,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
response.HttpHeaders.ContentMd5 = response_http_headers_content_md5_iterator->second;
|
||||
}
|
||||
auto x_ms_blob_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-blob-content-md5");
|
||||
if (x_ms_blob_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.HttpHeaders.ContentMd5 = x_ms_blob_content_md5_iterator->second;
|
||||
}
|
||||
auto response_http_headers_content_disposition_iterator
|
||||
= httpResponse.GetHeaders().find("content-disposition");
|
||||
if (response_http_headers_content_disposition_iterator != httpResponse.GetHeaders().end())
|
||||
@ -4949,7 +4961,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
response.Metadata.emplace(i->first.substr(10), i->second);
|
||||
}
|
||||
auto response_server_encrypted_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-request-server-encrypted");
|
||||
= httpResponse.GetHeaders().find("x-ms-server-encrypted");
|
||||
if (response_server_encrypted_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ServerEncrypted = response_server_encrypted_iterator->second == "true";
|
||||
@ -5057,9 +5069,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Nullable<std::string> IfNoneMatch;
|
||||
}; // struct DeleteBlobOptions
|
||||
|
||||
static Azure::Core::Response<DeleteBlobResult> Delete(
|
||||
const Azure::Core::Context& context,
|
||||
Azure::Core::Http::HttpPipeline& pipeline,
|
||||
static Azure::Core::Http::Request DeleteCreateMessage(
|
||||
const std::string& url,
|
||||
const DeleteBlobOptions& options)
|
||||
{
|
||||
@ -5096,7 +5106,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
request.AddHeader("If-None-Match", options.IfNoneMatch.GetValue());
|
||||
}
|
||||
auto pHttpResponse = pipeline.Send(context, request);
|
||||
return request;
|
||||
}
|
||||
|
||||
static Azure::Core::Response<DeleteBlobResult> DeleteCreateResponse(
|
||||
const Azure::Core::Context& context,
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> pHttpResponse)
|
||||
{
|
||||
unused(context);
|
||||
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
|
||||
DeleteBlobResult response;
|
||||
auto http_status_code
|
||||
@ -5110,6 +5127,17 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::move(response), std::move(pHttpResponse));
|
||||
}
|
||||
|
||||
static Azure::Core::Response<DeleteBlobResult> Delete(
|
||||
const Azure::Core::Context& context,
|
||||
Azure::Core::Http::HttpPipeline& pipeline,
|
||||
const std::string& url,
|
||||
const DeleteBlobOptions& options)
|
||||
{
|
||||
auto request = DeleteCreateMessage(url, options);
|
||||
auto pHttpResponse = pipeline.Send(context, request);
|
||||
return DeleteCreateResponse(context, std::move(pHttpResponse));
|
||||
}
|
||||
|
||||
struct UndeleteBlobOptions
|
||||
{
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
@ -5273,6 +5301,12 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
response.HttpHeaders.ContentMd5 = response_http_headers_content_md5_iterator->second;
|
||||
}
|
||||
auto x_ms_blob_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-blob-content-md5");
|
||||
if (x_ms_blob_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.HttpHeaders.ContentMd5 = x_ms_blob_content_md5_iterator->second;
|
||||
}
|
||||
auto response_http_headers_content_disposition_iterator
|
||||
= httpResponse.GetHeaders().find("content-disposition");
|
||||
if (response_http_headers_content_disposition_iterator != httpResponse.GetHeaders().end())
|
||||
@ -5298,7 +5332,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
response.IsSealed = response_is_sealed_iterator->second == "true";
|
||||
}
|
||||
auto response_server_encrypted_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-request-server-encrypted");
|
||||
= httpResponse.GetHeaders().find("x-ms-server-encrypted");
|
||||
if (response_server_encrypted_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ServerEncrypted = response_server_encrypted_iterator->second == "true";
|
||||
@ -5603,9 +5637,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Nullable<Blobs::RehydratePriority> RehydratePriority;
|
||||
}; // struct SetBlobAccessTierOptions
|
||||
|
||||
static Azure::Core::Response<SetBlobAccessTierResult> SetAccessTier(
|
||||
const Azure::Core::Context& context,
|
||||
Azure::Core::Http::HttpPipeline& pipeline,
|
||||
static Azure::Core::Http::Request SetAccessTierCreateMessage(
|
||||
const std::string& url,
|
||||
const SetBlobAccessTierOptions& options)
|
||||
{
|
||||
@ -5625,7 +5657,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
"x-ms-rehydrate-priority",
|
||||
RehydratePriorityToString(options.RehydratePriority.GetValue()));
|
||||
}
|
||||
auto pHttpResponse = pipeline.Send(context, request);
|
||||
return request;
|
||||
}
|
||||
|
||||
static Azure::Core::Response<SetBlobAccessTierResult> SetAccessTierCreateResponse(
|
||||
const Azure::Core::Context& context,
|
||||
std::unique_ptr<Azure::Core::Http::RawResponse> pHttpResponse)
|
||||
{
|
||||
unused(context);
|
||||
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
|
||||
SetBlobAccessTierResult response;
|
||||
auto http_status_code
|
||||
@ -5639,6 +5678,17 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::move(response), std::move(pHttpResponse));
|
||||
}
|
||||
|
||||
static Azure::Core::Response<SetBlobAccessTierResult> SetAccessTier(
|
||||
const Azure::Core::Context& context,
|
||||
Azure::Core::Http::HttpPipeline& pipeline,
|
||||
const std::string& url,
|
||||
const SetBlobAccessTierOptions& options)
|
||||
{
|
||||
auto request = SetAccessTierCreateMessage(url, options);
|
||||
auto pHttpResponse = pipeline.Send(context, request);
|
||||
return SetAccessTierCreateResponse(context, std::move(pHttpResponse));
|
||||
}
|
||||
|
||||
struct StartCopyBlobFromUriOptions
|
||||
{
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
@ -6257,8 +6307,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
struct UploadBlockBlobOptions
|
||||
{
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
BlobHttpHeaders HttpHeaders;
|
||||
std::map<std::string, std::string> Metadata;
|
||||
Azure::Core::Nullable<std::string> LeaseId;
|
||||
@ -6307,13 +6357,13 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
request.AddHeader("x-ms-encryption-scope", options.EncryptionScope.GetValue());
|
||||
}
|
||||
if (options.ContentMd5.HasValue())
|
||||
if (options.TransactionalContentMd5.HasValue())
|
||||
{
|
||||
request.AddHeader("Content-MD5", options.ContentMd5.GetValue());
|
||||
request.AddHeader("Content-MD5", options.TransactionalContentMd5.GetValue());
|
||||
}
|
||||
if (options.ContentCrc64.HasValue())
|
||||
if (options.TransactionalContentCrc64.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-content-crc64", options.ContentCrc64.GetValue());
|
||||
request.AddHeader("x-ms-content-crc64", options.TransactionalContentCrc64.GetValue());
|
||||
}
|
||||
if (!options.HttpHeaders.ContentType.empty())
|
||||
{
|
||||
@ -6391,15 +6441,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
response.ETag = httpResponse.GetHeaders().at("etag");
|
||||
response.LastModified = httpResponse.GetHeaders().at("last-modified");
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
auto response_version_id_iterator = httpResponse.GetHeaders().find("x-ms-version-id");
|
||||
if (response_version_id_iterator != httpResponse.GetHeaders().end())
|
||||
@ -6432,8 +6485,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
std::string BlockId;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<std::string> LeaseId;
|
||||
Azure::Core::Nullable<std::string> EncryptionKey;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
@ -6459,13 +6512,13 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
request.AddQueryParameter("timeout", std::to_string(options.Timeout.GetValue()));
|
||||
}
|
||||
if (options.ContentMd5.HasValue())
|
||||
if (options.TransactionalContentMd5.HasValue())
|
||||
{
|
||||
request.AddHeader("Content-MD5", options.ContentMd5.GetValue());
|
||||
request.AddHeader("Content-MD5", options.TransactionalContentMd5.GetValue());
|
||||
}
|
||||
if (options.ContentCrc64.HasValue())
|
||||
if (options.TransactionalContentCrc64.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-content-crc64", options.ContentCrc64.GetValue());
|
||||
request.AddHeader("x-ms-content-crc64", options.TransactionalContentCrc64.GetValue());
|
||||
}
|
||||
if (options.LeaseId.HasValue())
|
||||
{
|
||||
@ -6499,15 +6552,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
throw StorageError::CreateFromResponse(std::move(pHttpResponse));
|
||||
}
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
auto response_server_encrypted_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-request-server-encrypted");
|
||||
@ -6537,8 +6593,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::string BlockId;
|
||||
std::string SourceUri;
|
||||
Azure::Core::Nullable<std::pair<int64_t, int64_t>> SourceRange;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<std::string> LeaseId;
|
||||
Azure::Core::Nullable<std::string> EncryptionKey;
|
||||
Azure::Core::Nullable<std::string> EncryptionKeySha256;
|
||||
@ -6582,13 +6638,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
request.AddHeader("x-ms-source_range", "bytes=" + std::to_string(startOffset) + "-");
|
||||
}
|
||||
}
|
||||
if (options.ContentMd5.HasValue())
|
||||
if (options.TransactionalContentMd5.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-source-content-md5", options.ContentMd5.GetValue());
|
||||
request.AddHeader("x-ms-source-content-md5", options.TransactionalContentMd5.GetValue());
|
||||
}
|
||||
if (options.ContentCrc64.HasValue())
|
||||
if (options.TransactionalContentCrc64.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-source-content-crc64", options.ContentCrc64.GetValue());
|
||||
request.AddHeader(
|
||||
"x-ms-source-content-crc64", options.TransactionalContentCrc64.GetValue());
|
||||
}
|
||||
if (options.LeaseId.HasValue())
|
||||
{
|
||||
@ -6640,15 +6697,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
throw StorageError::CreateFromResponse(std::move(pHttpResponse));
|
||||
}
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
auto response_server_encrypted_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-request-server-encrypted");
|
||||
@ -7204,8 +7264,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
std::pair<int64_t, int64_t> Range;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<std::string> LeaseId;
|
||||
Azure::Core::Nullable<int64_t> IfSequenceNumberLessThanOrEqualTo;
|
||||
Azure::Core::Nullable<int64_t> IfSequenceNumberLessThan;
|
||||
@ -7241,13 +7301,13 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
"x-ms-range",
|
||||
"bytes=" + std::to_string(options.Range.first) + "-"
|
||||
+ std::to_string(options.Range.second));
|
||||
if (options.ContentMd5.HasValue())
|
||||
if (options.TransactionalContentMd5.HasValue())
|
||||
{
|
||||
request.AddHeader("Content-MD5", options.ContentMd5.GetValue());
|
||||
request.AddHeader("Content-MD5", options.TransactionalContentMd5.GetValue());
|
||||
}
|
||||
if (options.ContentCrc64.HasValue())
|
||||
if (options.TransactionalContentCrc64.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-content-crc64", options.ContentCrc64.GetValue());
|
||||
request.AddHeader("x-ms-content-crc64", options.TransactionalContentCrc64.GetValue());
|
||||
}
|
||||
request.AddHeader("x-ms-page-write", "update");
|
||||
if (options.LeaseId.HasValue())
|
||||
@ -7318,15 +7378,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
response.ETag = httpResponse.GetHeaders().at("etag");
|
||||
response.LastModified = httpResponse.GetHeaders().at("last-modified");
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
response.SequenceNumber
|
||||
= std::stoll(httpResponse.GetHeaders().at("x-ms-blob-sequence-number"));
|
||||
@ -7358,8 +7421,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::string SourceUri;
|
||||
std::pair<int64_t, int64_t> SourceRange;
|
||||
std::pair<int64_t, int64_t> Range;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<std::string> LeaseId;
|
||||
Azure::Core::Nullable<int64_t> IfSequenceNumberLessThanOrEqualTo;
|
||||
Azure::Core::Nullable<int64_t> IfSequenceNumberLessThan;
|
||||
@ -7398,13 +7461,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
"x-ms-source-range",
|
||||
"bytes=" + std::to_string(options.SourceRange.first) + "-"
|
||||
+ std::to_string(options.SourceRange.second));
|
||||
if (options.ContentMd5.HasValue())
|
||||
if (options.TransactionalContentMd5.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-source-content-md5", options.ContentMd5.GetValue());
|
||||
request.AddHeader("x-ms-source-content-md5", options.TransactionalContentMd5.GetValue());
|
||||
}
|
||||
if (options.ContentCrc64.HasValue())
|
||||
if (options.TransactionalContentCrc64.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-source-content-crc64", options.ContentCrc64.GetValue());
|
||||
request.AddHeader(
|
||||
"x-ms-source-content-crc64", options.TransactionalContentCrc64.GetValue());
|
||||
}
|
||||
request.AddHeader("x-ms-page-write", "update");
|
||||
if (options.LeaseId.HasValue())
|
||||
@ -7475,15 +7539,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
response.ETag = httpResponse.GetHeaders().at("etag");
|
||||
response.LastModified = httpResponse.GetHeaders().at("last-modified");
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
response.SequenceNumber
|
||||
= std::stoll(httpResponse.GetHeaders().at("x-ms-blob-sequence-number"));
|
||||
@ -8227,8 +8294,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
struct AppendBlockOptions
|
||||
{
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<std::string> LeaseId;
|
||||
Azure::Core::Nullable<int64_t> MaxSize;
|
||||
Azure::Core::Nullable<int64_t> AppendPosition;
|
||||
@ -8259,13 +8326,13 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
request.AddQueryParameter("timeout", std::to_string(options.Timeout.GetValue()));
|
||||
}
|
||||
if (options.ContentMd5.HasValue())
|
||||
if (options.TransactionalContentMd5.HasValue())
|
||||
{
|
||||
request.AddHeader("Content-MD5", options.ContentMd5.GetValue());
|
||||
request.AddHeader("Content-MD5", options.TransactionalContentMd5.GetValue());
|
||||
}
|
||||
if (options.ContentCrc64.HasValue())
|
||||
if (options.TransactionalContentCrc64.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-content-crc64", options.ContentCrc64.GetValue());
|
||||
request.AddHeader("x-ms-content-crc64", options.TransactionalContentCrc64.GetValue());
|
||||
}
|
||||
if (options.LeaseId.HasValue())
|
||||
{
|
||||
@ -8327,15 +8394,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
response.ETag = httpResponse.GetHeaders().at("etag");
|
||||
response.LastModified = httpResponse.GetHeaders().at("last-modified");
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
response.AppendOffset = std::stoll(httpResponse.GetHeaders().at("x-ms-blob-append-offset"));
|
||||
response.CommittedBlockCount
|
||||
@ -8367,8 +8437,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
std::string SourceUri;
|
||||
Azure::Core::Nullable<std::pair<int64_t, int64_t>> SourceRange;
|
||||
Azure::Core::Nullable<std::string> ContentMd5;
|
||||
Azure::Core::Nullable<std::string> ContentCrc64;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentMd5;
|
||||
Azure::Core::Nullable<std::string> TransactionalContentCrc64;
|
||||
Azure::Core::Nullable<std::string> LeaseId;
|
||||
Azure::Core::Nullable<int64_t> MaxSize;
|
||||
Azure::Core::Nullable<int64_t> AppendPosition;
|
||||
@ -8413,13 +8483,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
request.AddHeader("x-ms-source-range", "bytes=" + std::to_string(startOffset) + "-");
|
||||
}
|
||||
}
|
||||
if (options.ContentMd5.HasValue())
|
||||
if (options.TransactionalContentMd5.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-source-content-md5", options.ContentMd5.GetValue());
|
||||
request.AddHeader("x-ms-source-content-md5", options.TransactionalContentMd5.GetValue());
|
||||
}
|
||||
if (options.ContentCrc64.HasValue())
|
||||
if (options.TransactionalContentCrc64.HasValue())
|
||||
{
|
||||
request.AddHeader("x-ms-source-content-crc64", options.ContentCrc64.GetValue());
|
||||
request.AddHeader(
|
||||
"x-ms-source-content-crc64", options.TransactionalContentCrc64.GetValue());
|
||||
}
|
||||
if (options.LeaseId.HasValue())
|
||||
{
|
||||
@ -8481,15 +8552,18 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
response.ETag = httpResponse.GetHeaders().at("etag");
|
||||
response.LastModified = httpResponse.GetHeaders().at("last-modified");
|
||||
auto response_content_md5_iterator = httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_md5_iterator
|
||||
= httpResponse.GetHeaders().find("content-md5");
|
||||
if (response_transactional_content_md5_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentMd5 = response_content_md5_iterator->second;
|
||||
response.TransactionalContentMd5 = response_transactional_content_md5_iterator->second;
|
||||
}
|
||||
auto response_content_crc64_iterator = httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
auto response_transactional_content_crc64_iterator
|
||||
= httpResponse.GetHeaders().find("x-ms-content-crc64");
|
||||
if (response_transactional_content_crc64_iterator != httpResponse.GetHeaders().end())
|
||||
{
|
||||
response.ContentCrc64 = response_content_crc64_iterator->second;
|
||||
response.TransactionalContentCrc64
|
||||
= response_transactional_content_crc64_iterator->second;
|
||||
}
|
||||
response.AppendOffset = std::stoll(httpResponse.GetHeaders().at("x-ms-blob-append-offset"));
|
||||
response.CommittedBlockCount
|
||||
@ -8586,5 +8660,49 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
private:
|
||||
}; // class AppendBlob
|
||||
|
||||
class BlobBatch {
|
||||
public:
|
||||
struct SubmitBlobBatchOptions
|
||||
{
|
||||
Azure::Core::Nullable<int32_t> Timeout;
|
||||
std::string ContentType;
|
||||
}; // struct SubmitBlobBatchOptions
|
||||
|
||||
static Azure::Core::Response<SubmitBlobBatchResultInternal> SubmitBatch(
|
||||
const Azure::Core::Context& context,
|
||||
Azure::Core::Http::HttpPipeline& pipeline,
|
||||
const std::string& url,
|
||||
Azure::Core::Http::BodyStream* requestBody,
|
||||
const SubmitBlobBatchOptions& options)
|
||||
{
|
||||
unused(options);
|
||||
auto request
|
||||
= Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Post, url, requestBody);
|
||||
request.AddHeader("Content-Length", std::to_string(requestBody->Length()));
|
||||
request.AddQueryParameter("comp", "batch");
|
||||
request.AddHeader("x-ms-version", c_ApiVersion);
|
||||
if (options.Timeout.HasValue())
|
||||
{
|
||||
request.AddQueryParameter("timeout", std::to_string(options.Timeout.GetValue()));
|
||||
}
|
||||
request.AddHeader("Content-Type", options.ContentType);
|
||||
auto pHttpResponse = pipeline.Send(context, request);
|
||||
Azure::Core::Http::RawResponse& httpResponse = *pHttpResponse;
|
||||
SubmitBlobBatchResultInternal response;
|
||||
auto http_status_code
|
||||
= static_cast<std::underlying_type<Azure::Core::Http::HttpStatusCode>::type>(
|
||||
httpResponse.GetStatusCode());
|
||||
if (!(http_status_code == 202))
|
||||
{
|
||||
throw StorageError::CreateFromResponse(std::move(pHttpResponse));
|
||||
}
|
||||
response.ContentType = httpResponse.GetHeaders().at("content-type");
|
||||
return Azure::Core::Response<SubmitBlobBatchResultInternal>(
|
||||
std::move(response), std::move(pHttpResponse));
|
||||
}
|
||||
|
||||
private:
|
||||
}; // class BlobBatch
|
||||
|
||||
}; // class BlobRestClient
|
||||
}}} // namespace Azure::Storage::Blobs
|
||||
|
||||
@ -99,8 +99,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const AppendBlockOptions& options) const
|
||||
{
|
||||
BlobRestClient::AppendBlob::AppendBlockOptions protocolLayerOptions;
|
||||
protocolLayerOptions.ContentMd5 = options.ContentMd5;
|
||||
protocolLayerOptions.ContentCrc64 = options.ContentCrc64;
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
protocolLayerOptions.MaxSize = options.AccessConditions.MaxSize;
|
||||
protocolLayerOptions.AppendPosition = options.AccessConditions.AppendPosition;
|
||||
@ -138,8 +138,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::numeric_limits<
|
||||
std::remove_reference_t<decltype(options.SourceOffset.GetValue())>>::max());
|
||||
}
|
||||
protocolLayerOptions.ContentMd5 = options.ContentMd5;
|
||||
protocolLayerOptions.ContentCrc64 = options.ContentCrc64;
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
protocolLayerOptions.MaxSize = options.AccessConditions.MaxSize;
|
||||
protocolLayerOptions.AppendPosition = options.AccessConditions.AppendPosition;
|
||||
|
||||
@ -163,7 +163,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_containerUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
Azure::Core::Response<UndeleteContainerResult> BlobContainerClient::UndeleteContainer(
|
||||
Azure::Core::Response<UndeleteContainerResult> BlobContainerClient::Undelete(
|
||||
const std::string& deletedContainerName,
|
||||
const std::string& deletedContainerVersion,
|
||||
const UndeleteContainerOptions& options) const
|
||||
|
||||
@ -80,8 +80,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
const UploadBlockBlobOptions& options) const
|
||||
{
|
||||
BlobRestClient::BlockBlob::UploadBlockBlobOptions protocolLayerOptions;
|
||||
protocolLayerOptions.ContentMd5 = options.ContentMd5;
|
||||
protocolLayerOptions.ContentCrc64 = options.ContentCrc64;
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.HttpHeaders = options.HttpHeaders;
|
||||
protocolLayerOptions.Metadata = options.Metadata;
|
||||
protocolLayerOptions.Tier = options.Tier;
|
||||
@ -268,8 +268,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
{
|
||||
BlobRestClient::BlockBlob::StageBlockOptions protocolLayerOptions;
|
||||
protocolLayerOptions.BlockId = blockId;
|
||||
protocolLayerOptions.ContentMd5 = options.ContentMd5;
|
||||
protocolLayerOptions.ContentCrc64 = options.ContentCrc64;
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
if (m_customerProvidedKey.HasValue())
|
||||
{
|
||||
@ -303,8 +303,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
std::numeric_limits<
|
||||
std::remove_reference_t<decltype(options.SourceOffset.GetValue())>>::max());
|
||||
}
|
||||
protocolLayerOptions.ContentMd5 = options.ContentMd5;
|
||||
protocolLayerOptions.ContentCrc64 = options.ContentCrc64;
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
protocolLayerOptions.SourceIfModifiedSince = options.SourceConditions.IfModifiedSince;
|
||||
protocolLayerOptions.SourceIfUnmodifiedSince = options.SourceConditions.IfUnmodifiedSince;
|
||||
|
||||
@ -99,14 +99,14 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadPageBlobPagesResult> PageBlobClient::UploadPages(
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
int64_t offset,
|
||||
Azure::Core::Http::BodyStream* content,
|
||||
const UploadPageBlobPagesOptions& options) const
|
||||
{
|
||||
BlobRestClient::PageBlob::UploadPageBlobPagesOptions protocolLayerOptions;
|
||||
protocolLayerOptions.Range = std::make_pair(offset, offset + content->Length() - 1);
|
||||
protocolLayerOptions.ContentMd5 = options.ContentMd5;
|
||||
protocolLayerOptions.ContentCrc64 = options.ContentCrc64;
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
|
||||
protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
|
||||
@ -124,10 +124,10 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadPageBlobPagesFromUriResult> PageBlobClient::UploadPagesFromUri(
|
||||
int64_t destinationoffset,
|
||||
std::string sourceUri,
|
||||
int64_t sourceOffset,
|
||||
int64_t sourceLength,
|
||||
int64_t destinationoffset,
|
||||
const UploadPageBlobPagesFromUriOptions& options) const
|
||||
{
|
||||
BlobRestClient::PageBlob::UploadPageBlobPagesFromUriOptions protocolLayerOptions;
|
||||
@ -136,8 +136,8 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
= std::make_pair(sourceOffset, sourceOffset + sourceLength - 1);
|
||||
protocolLayerOptions.Range
|
||||
= std::make_pair(destinationoffset, destinationoffset + sourceLength - 1);
|
||||
protocolLayerOptions.ContentMd5 = options.ContentMd5;
|
||||
protocolLayerOptions.ContentCrc64 = options.ContentCrc64;
|
||||
protocolLayerOptions.TransactionalContentMd5 = options.TransactionalContentMd5;
|
||||
protocolLayerOptions.TransactionalContentCrc64 = options.TransactionalContentCrc64;
|
||||
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
|
||||
protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
|
||||
protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
|
||||
@ -177,94 +177,6 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), protocolLayerOptions);
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadPageBlobFromResult> PageBlobClient::UploadFrom(
|
||||
const uint8_t* buffer,
|
||||
std::size_t bufferSize,
|
||||
const UploadPageBlobFromOptions& options) const
|
||||
{
|
||||
BlobRestClient::PageBlob::CreatePageBlobOptions createOptions;
|
||||
createOptions.BlobContentLength = bufferSize;
|
||||
createOptions.HttpHeaders = options.HttpHeaders;
|
||||
createOptions.Metadata = options.Metadata;
|
||||
createOptions.Tier = options.Tier;
|
||||
if (m_customerProvidedKey.HasValue())
|
||||
{
|
||||
createOptions.EncryptionKey = m_customerProvidedKey.GetValue().Key;
|
||||
createOptions.EncryptionKeySha256 = m_customerProvidedKey.GetValue().KeyHash;
|
||||
createOptions.EncryptionAlgorithm = m_customerProvidedKey.GetValue().Algorithm;
|
||||
}
|
||||
createOptions.EncryptionScope = m_encryptionScope;
|
||||
auto createResult = BlobRestClient::PageBlob::Create(
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), createOptions);
|
||||
|
||||
constexpr int64_t c_defaultChunkSize = 8 * 1024 * 1024;
|
||||
int64_t chunkSize
|
||||
= options.ChunkSize.HasValue() ? options.ChunkSize.GetValue() : c_defaultChunkSize;
|
||||
|
||||
auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
|
||||
unused(chunkId, numChunks);
|
||||
Azure::Core::Http::MemoryBodyStream contentStream(buffer + offset, length);
|
||||
UploadPageBlobPagesOptions uploadPagesOptions;
|
||||
uploadPagesOptions.Context = options.Context;
|
||||
UploadPages(&contentStream, offset, uploadPagesOptions);
|
||||
};
|
||||
|
||||
Details::ConcurrentTransfer(0, bufferSize, chunkSize, options.Concurrency, uploadPageFunc);
|
||||
|
||||
UploadPageBlobFromResult result;
|
||||
result.ServerEncrypted = createResult->ServerEncrypted;
|
||||
result.EncryptionKeySha256 = createResult->EncryptionKeySha256;
|
||||
result.EncryptionScope = createResult->EncryptionScope;
|
||||
return Azure::Core::Response<UploadPageBlobFromResult>(
|
||||
std::move(result),
|
||||
std::make_unique<Azure::Core::Http::RawResponse>(std::move(createResult.GetRawResponse())));
|
||||
}
|
||||
|
||||
Azure::Core::Response<UploadPageBlobFromResult> PageBlobClient::UploadFrom(
|
||||
const std::string& file,
|
||||
const UploadPageBlobFromOptions& options) const
|
||||
{
|
||||
Details::FileReader fileReader(file);
|
||||
|
||||
BlobRestClient::PageBlob::CreatePageBlobOptions createOptions;
|
||||
createOptions.BlobContentLength = fileReader.GetFileSize();
|
||||
createOptions.HttpHeaders = options.HttpHeaders;
|
||||
createOptions.Metadata = options.Metadata;
|
||||
createOptions.Tier = options.Tier;
|
||||
if (m_customerProvidedKey.HasValue())
|
||||
{
|
||||
createOptions.EncryptionKey = m_customerProvidedKey.GetValue().Key;
|
||||
createOptions.EncryptionKeySha256 = m_customerProvidedKey.GetValue().KeyHash;
|
||||
createOptions.EncryptionAlgorithm = m_customerProvidedKey.GetValue().Algorithm;
|
||||
}
|
||||
createOptions.EncryptionScope = m_encryptionScope;
|
||||
auto createResult = BlobRestClient::PageBlob::Create(
|
||||
options.Context, *m_pipeline, m_blobUrl.ToString(), createOptions);
|
||||
|
||||
constexpr int64_t c_defaultChunkSize = 8 * 1024 * 1024;
|
||||
int64_t chunkSize
|
||||
= options.ChunkSize.HasValue() ? options.ChunkSize.GetValue() : c_defaultChunkSize;
|
||||
|
||||
auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
|
||||
unused(chunkId, numChunks);
|
||||
Azure::Core::Http::FileBodyStream contentStream(fileReader.GetHandle(), offset, length);
|
||||
UploadPageBlobPagesOptions uploadPagesOptions;
|
||||
uploadPagesOptions.Context = options.Context;
|
||||
UploadPages(&contentStream, offset, uploadPagesOptions);
|
||||
};
|
||||
|
||||
Details::ConcurrentTransfer(
|
||||
0, fileReader.GetFileSize(), chunkSize, options.Concurrency, uploadPageFunc);
|
||||
|
||||
UploadPageBlobFromResult result;
|
||||
result.ServerEncrypted = createResult->ServerEncrypted;
|
||||
result.EncryptionKeySha256 = createResult->EncryptionKeySha256;
|
||||
result.EncryptionScope = createResult->EncryptionScope;
|
||||
return Azure::Core::Response<UploadPageBlobFromResult>(
|
||||
std::move(result),
|
||||
std::make_unique<Azure::Core::Http::RawResponse>(std::move(createResult.GetRawResponse())));
|
||||
}
|
||||
|
||||
Azure::Core::Response<ResizePageBlobResult> PageBlobClient::Resize(
|
||||
int64_t blobContentLength,
|
||||
const ResizePageBlobOptions& options) const
|
||||
|
||||
@ -588,10 +588,10 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
options.CustomerProvidedKey.GetValue().KeyHash);
|
||||
bodyStream.Rewind();
|
||||
EXPECT_NO_THROW(pageBlob.Resize(blobContent.size()));
|
||||
EXPECT_NO_THROW(pageBlob.UploadPages(&bodyStream, 0));
|
||||
EXPECT_NO_THROW(pageBlob.UploadPages(0, &bodyStream));
|
||||
EXPECT_NO_THROW(pageBlob.ClearPages(0, blobContent.size()));
|
||||
EXPECT_NO_THROW(pageBlob.UploadPagesFromUri(
|
||||
copySourceBlob.GetUri() + GetSas(), 0, blobContent.size(), 0));
|
||||
0, copySourceBlob.GetUri() + GetSas(), 0, blobContent.size()));
|
||||
|
||||
auto pageBlobClientWithoutEncryptionKey
|
||||
= Azure::Storage::Blobs::PageBlobClient::CreateFromConnectionString(
|
||||
@ -712,7 +712,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
{
|
||||
try
|
||||
{
|
||||
containerClient2.UndeleteContainer(
|
||||
containerClient2.Undelete(
|
||||
deletedContainerItem.Name, deletedContainerItem.VersionId.GetValue());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
m_pageBlobClient->Create(m_blobContent.size(), m_blobUploadOptions);
|
||||
auto pageContent
|
||||
= Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size());
|
||||
m_pageBlobClient->UploadPages(&pageContent, 0);
|
||||
m_pageBlobClient->UploadPages(0, &pageContent);
|
||||
m_blobUploadOptions.HttpHeaders.ContentMd5
|
||||
= m_pageBlobClient->GetProperties()->HttpHeaders.ContentMd5;
|
||||
}
|
||||
@ -83,7 +83,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
StandardStorageConnectionString(), m_containerName, RandomString());
|
||||
pageBlobClient.Create(8_KB, m_blobUploadOptions);
|
||||
auto pageContent = Azure::Core::Http::MemoryBodyStream(blobContent.data(), blobContent.size());
|
||||
pageBlobClient.UploadPages(&pageContent, 2_KB);
|
||||
pageBlobClient.UploadPages(2_KB, &pageContent);
|
||||
// |_|_|x|x| |x|x|_|_|
|
||||
blobContent.insert(blobContent.begin(), static_cast<std::size_t>(2_KB), '\x00');
|
||||
blobContent.resize(static_cast<std::size_t>(8_KB), '\x00');
|
||||
@ -116,7 +116,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
// |_|_|_|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());
|
||||
pageBlobClient.UploadPages(&pageClient, 0);
|
||||
pageBlobClient.UploadPages(0, &pageClient);
|
||||
pageBlobClient.ClearPages(3_KB, 1_KB);
|
||||
// |x|_|_|_| |x|x|_|_|
|
||||
|
||||
@ -137,7 +137,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
StandardStorageConnectionString(), m_containerName, RandomString());
|
||||
pageBlobClient.Create(m_blobContent.size(), m_blobUploadOptions);
|
||||
pageBlobClient.UploadPagesFromUri(
|
||||
m_pageBlobClient->GetUri() + GetSas(), 0, m_blobContent.size(), 0);
|
||||
0, m_pageBlobClient->GetUri() + GetSas(), 0, m_blobContent.size());
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, StartCopyIncremental)
|
||||
@ -221,12 +221,13 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto pageContent = Azure::Core::Http::MemoryBodyStream(blobContent.data(), blobContent.size());
|
||||
|
||||
Blobs::UploadPageBlobPagesOptions options;
|
||||
options.ContentMd5 = Base64Encode(Md5::Hash(blobContent.data(), blobContent.size()));
|
||||
EXPECT_NO_THROW(pageBlobClient.UploadPages(&pageContent, 0, options));
|
||||
options.TransactionalContentMd5
|
||||
= Base64Encode(Md5::Hash(blobContent.data(), blobContent.size()));
|
||||
EXPECT_NO_THROW(pageBlobClient.UploadPages(0, &pageContent, options));
|
||||
|
||||
pageContent.Rewind();
|
||||
options.ContentMd5 = c_dummyMd5;
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(&pageContent, 0, options), StorageError);
|
||||
options.TransactionalContentMd5 = c_dummyMd5;
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &pageContent, options), StorageError);
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, ContentCrc64)
|
||||
@ -241,117 +242,13 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
auto pageContent = Azure::Core::Http::MemoryBodyStream(blobContent.data(), blobContent.size());
|
||||
|
||||
Blobs::UploadPageBlobPagesOptions options;
|
||||
options.ContentCrc64 = Base64Encode(Crc64::Hash(blobContent.data(), blobContent.size()));
|
||||
EXPECT_NO_THROW(pageBlobClient.UploadPages(&pageContent, 0, options));
|
||||
options.TransactionalContentCrc64
|
||||
= Base64Encode(Crc64::Hash(blobContent.data(), blobContent.size()));
|
||||
EXPECT_NO_THROW(pageBlobClient.UploadPages(0, &pageContent, options));
|
||||
|
||||
pageContent.Rewind();
|
||||
options.ContentCrc64 = c_dummyCrc64;
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(&pageContent, 0, options), StorageError);
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, ConcurrentUploadFromNonExistingFile)
|
||||
{
|
||||
auto pageBlobClient = m_blobContainerClient->GetPageBlobClient(RandomString());
|
||||
std::string emptyFilename = RandomString();
|
||||
EXPECT_THROW(pageBlobClient.UploadFrom(emptyFilename), std::runtime_error);
|
||||
EXPECT_THROW(pageBlobClient.Delete(), StorageError);
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, ConcurrentUploadEmptyBlob)
|
||||
{
|
||||
auto pageBlobClient = m_blobContainerClient->GetPageBlobClient(RandomString());
|
||||
|
||||
std::vector<uint8_t> emptyContent;
|
||||
pageBlobClient.UploadFrom(emptyContent.data(), emptyContent.size());
|
||||
EXPECT_NO_THROW(pageBlobClient.Delete());
|
||||
|
||||
std::string emptyFilename = RandomString();
|
||||
{
|
||||
Details::FileWriter writer(emptyFilename);
|
||||
}
|
||||
pageBlobClient.UploadFrom(emptyFilename);
|
||||
EXPECT_NO_THROW(pageBlobClient.Delete());
|
||||
|
||||
DeleteFile(emptyFilename);
|
||||
}
|
||||
|
||||
TEST_F(PageBlobClientTest, ConcurrentUpload)
|
||||
{
|
||||
std::vector<uint8_t> blobContent = RandomBuffer(static_cast<std::size_t>(8_MB));
|
||||
|
||||
auto testUploadFromBuffer = [&](int concurrency, int64_t blobSize) {
|
||||
auto pageBlobClient = m_blobContainerClient->GetPageBlobClient(RandomString());
|
||||
|
||||
Azure::Storage::Blobs::UploadPageBlobFromOptions options;
|
||||
options.ChunkSize = 512_KB;
|
||||
options.Concurrency = concurrency;
|
||||
options.HttpHeaders = m_blobUploadOptions.HttpHeaders;
|
||||
options.HttpHeaders.ContentMd5.clear();
|
||||
options.Metadata = m_blobUploadOptions.Metadata;
|
||||
|
||||
auto res = pageBlobClient.UploadFrom(
|
||||
blobContent.data(), static_cast<std::size_t>(blobSize), options);
|
||||
EXPECT_TRUE(res->ServerEncrypted.HasValue());
|
||||
|
||||
auto properties = *pageBlobClient.GetProperties();
|
||||
properties.HttpHeaders.ContentMd5.clear();
|
||||
EXPECT_EQ(properties.ContentLength, blobSize);
|
||||
EXPECT_EQ(properties.Metadata, options.Metadata);
|
||||
std::vector<uint8_t> downloadContent(static_cast<std::size_t>(blobSize), '\x00');
|
||||
pageBlobClient.DownloadTo(downloadContent.data(), static_cast<std::size_t>(blobSize));
|
||||
EXPECT_EQ(
|
||||
downloadContent,
|
||||
std::vector<uint8_t>(
|
||||
blobContent.begin(), blobContent.begin() + static_cast<std::size_t>(blobSize)));
|
||||
};
|
||||
|
||||
auto testUploadFromFile = [&](int concurrency, int64_t blobSize) {
|
||||
auto pageBlobClient = m_blobContainerClient->GetPageBlobClient(RandomString());
|
||||
|
||||
Azure::Storage::Blobs::UploadPageBlobFromOptions options;
|
||||
options.ChunkSize = 512_KB;
|
||||
options.Concurrency = concurrency;
|
||||
options.HttpHeaders = m_blobUploadOptions.HttpHeaders;
|
||||
options.HttpHeaders.ContentMd5.clear();
|
||||
options.Metadata = m_blobUploadOptions.Metadata;
|
||||
|
||||
std::string tempFilename = RandomString();
|
||||
{
|
||||
Azure::Storage::Details::FileWriter fileWriter(tempFilename);
|
||||
fileWriter.Write(blobContent.data(), blobSize, 0);
|
||||
}
|
||||
|
||||
auto res = pageBlobClient.UploadFrom(tempFilename, options);
|
||||
EXPECT_TRUE(res->ServerEncrypted.HasValue());
|
||||
|
||||
auto properties = *pageBlobClient.GetProperties();
|
||||
properties.HttpHeaders.ContentMd5.clear();
|
||||
EXPECT_EQ(properties.ContentLength, blobSize);
|
||||
EXPECT_EQ(properties.Metadata, options.Metadata);
|
||||
std::vector<uint8_t> downloadContent(static_cast<std::size_t>(blobSize), '\x00');
|
||||
pageBlobClient.DownloadTo(downloadContent.data(), static_cast<std::size_t>(blobSize));
|
||||
EXPECT_EQ(
|
||||
downloadContent,
|
||||
std::vector<uint8_t>(
|
||||
blobContent.begin(), blobContent.begin() + static_cast<std::size_t>(blobSize)));
|
||||
|
||||
DeleteFile(tempFilename);
|
||||
};
|
||||
|
||||
std::vector<std::future<void>> futures;
|
||||
for (int c : {1, 2, 5})
|
||||
{
|
||||
for (int64_t l : {0ULL, 512ULL, 1_KB, 4_KB, 1_MB, 4_MB + 512})
|
||||
{
|
||||
ASSERT_GE(blobContent.size(), static_cast<std::size_t>(l));
|
||||
futures.emplace_back(std::async(std::launch::async, testUploadFromBuffer, c, l));
|
||||
futures.emplace_back(std::async(std::launch::async, testUploadFromFile, c, l));
|
||||
}
|
||||
}
|
||||
for (auto& f : futures)
|
||||
{
|
||||
f.get();
|
||||
}
|
||||
options.TransactionalContentCrc64 = c_dummyCrc64;
|
||||
EXPECT_THROW(pageBlobClient.UploadPages(0, &pageContent, options), StorageError);
|
||||
}
|
||||
|
||||
}}} // namespace Azure::Storage::Test
|
||||
|
||||
@ -312,7 +312,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
}
|
||||
ret.RangeOffset = RangeOffset;
|
||||
ret.RangeLength = RangeLength;
|
||||
ret.TransactionalMd5 = std::move(result->ContentMd5);
|
||||
ret.TransactionalMd5 = std::move(result->TransactionalContentMd5);
|
||||
ret.ETag = std::move(result->ETag);
|
||||
ret.LastModified = std::move(result->LastModified);
|
||||
ret.LeaseDuration = std::move(result->LeaseDuration);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user