Refined list/download returned properties (#1579)

* Refined list/download returned properties

* align with blob/datalake

* Resolve clang format issue.
This commit is contained in:
Kan Tang 2021-02-03 18:23:50 +08:00 committed by GitHub
parent d0a6f7e8f8
commit 60cf8733cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 200 additions and 66 deletions

View File

@ -7,6 +7,7 @@
- Added support for `UploadRangeFromUri` in file client.
- Added support for `SetProperties` in share client. This API supports update share tier and adjusting share's quota.
- Added support to get share's tier status in `ListSharesSinglePage` and `GetProperties`.
- Added `ChangedOn`, `FileId`, `ParentId` to the `FileShareSmbProperties`.
### Breaking Changes
@ -25,6 +26,9 @@
- `Concurrency`, `ChunkSize` and `InitialChunkSize` were moved into `DownloadShareFileToOptions::TansferOptions`.
- `Concurrency`, `ChunkSize` and `SingleUploadThreshold` were moved into `UploadShareFileFromOptions::TransferOptions`.
- Removed `SetQuota` related API, result and options. The functionality is moved into `SetProperties`.
- Moved some less commonly used properties returned when downloading a file into a new structure called `DownloadShareFileDetails`. This will impact the return type of `ShareFileClient::Download` and `ShareFileClient::DownloadTo`.
- Renamed `FileProperty` to `FileItemDetails` to align with other SDK's naming pattern for returned items for list operation.
- Renamed `ShareProperties` to `ShareItemDetails` to align with other SDK's naming pattern for returned items for list operation.
### Other Changes and Improvements

View File

@ -152,7 +152,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
};
// File properties.
struct FileProperty
struct FileItemDetails
{
int64_t ContentLength
= int64_t(); // Content length of the file. This value may not be up-to-date since an SMB
@ -165,7 +165,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
struct FileItem
{
std::string Name;
FileProperty Properties;
FileItemDetails Details;
};
// A listed Azure Storage handle item.
@ -234,7 +234,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}; // extensible enum LeaseStatusType
// Properties of a share.
struct ShareProperties
struct ShareItemDetails
{
Core::DateTime LastModified;
Core::ETag Etag;
@ -260,7 +260,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
std::string Snapshot;
bool Deleted = bool();
std::string Version;
ShareProperties Properties;
ShareItemDetails Details;
Storage::Metadata ShareMetadata;
};
@ -2104,9 +2104,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
return result;
}
static ShareProperties SharePropertiesFromXml(Storage::Details::XmlReader& reader)
static ShareItemDetails ShareItemDetailsFromXml(Storage::Details::XmlReader& reader)
{
auto result = ShareProperties();
auto result = ShareItemDetails();
enum class XmlTagName
{
AccessTier,
@ -2390,7 +2390,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
if (path.size() == 1 && path[0] == XmlTagName::Properties)
{
result.Properties = SharePropertiesFromXml(reader);
result.Details = ShareItemDetailsFromXml(reader);
path.pop_back();
}
else if (path.size() == 1 && path[0] == XmlTagName::Metadata)
@ -4668,9 +4668,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
return result;
}
static FileProperty FilePropertyFromXml(Storage::Details::XmlReader& reader)
static FileItemDetails FileItemDetailsFromXml(Storage::Details::XmlReader& reader)
{
auto result = FileProperty();
auto result = FileItemDetails();
enum class XmlTagName
{
ContentLength,
@ -4766,7 +4766,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
if (path.size() == 1 && path[0] == XmlTagName::Properties)
{
result.Properties = FilePropertyFromXml(reader);
result.Details = FileItemDetailsFromXml(reader);
path.pop_back();
}
}

View File

@ -135,20 +135,84 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { names
FileAttributes Attributes = static_cast<FileAttributes>(0);
/**
* @brief Creation time for the file/directory..
* @brief Creation time for the file/directory.
*/
Azure::Core::Nullable<Core::DateTime> CreatedOn;
/**
* @brief Last write time for the file/directory..
* @brief Last write time for the file/directory.
*/
Azure::Core::Nullable<Core::DateTime> LastWrittenOn;
/**
* @brief Changed time for the file/directory.
*/
Azure::Core::Nullable<Core::DateTime> ChangedOn;
/**
* @brief The fileId of the file.
*/
std::string FileId;
/**
* @brief The parentId of the file
*/
std::string ParentId;
};
struct DownloadShareFileDetails
{
Core::DateTime LastModified;
Storage::Metadata Metadata;
Core::ETag ETag;
std::string AcceptRanges;
Azure::Core::Nullable<Core::DateTime> CopyCompletedOn;
Azure::Core::Nullable<std::string> CopyStatusDescription;
Azure::Core::Nullable<std::string> CopyId;
Azure::Core::Nullable<std::string> CopyProgress;
Azure::Core::Nullable<std::string> CopySource;
Azure::Core::Nullable<CopyStatusType> CopyStatus;
bool IsServerEncrypted = bool();
FileShareSmbProperties SmbProperties;
Azure::Core::Nullable<LeaseDurationType> LeaseDuration;
Azure::Core::Nullable<LeaseStateType> LeaseState;
Azure::Core::Nullable<LeaseStatusType> LeaseStatus;
};
struct DownloadShareFileResult
{
std::unique_ptr<Azure::Core::Http::BodyStream> BodyStream;
Azure::Core::Http::Range ContentRange;
int64_t FileSize;
Azure::Core::Nullable<Storage::ContentHash> TransactionalContentHash;
ShareFileHttpHeaders HttpHeaders;
DownloadShareFileDetails Details;
std::string RequestId;
};
using DownloadShareFileResult = Details::FileDownloadResult;
using StartCopyShareFileResult = Details::FileStartCopyResult;
using AbortCopyShareFileResult = Details::FileAbortCopyResult;
using GetShareFilePropertiesResult = Details::FileGetPropertiesResult;
struct GetShareFilePropertiesResult
{
Core::DateTime LastModified;
Storage::Metadata Metadata;
std::string FileType;
int64_t FileSize = int64_t();
ShareFileHttpHeaders HttpHeaders;
Core::ETag ETag;
std::string RequestId;
Azure::Core::Nullable<Core::DateTime> CopyCompletedOn;
Azure::Core::Nullable<std::string> CopyStatusDescription;
Azure::Core::Nullable<std::string> CopyId;
Azure::Core::Nullable<std::string> CopyProgress;
Azure::Core::Nullable<std::string> CopySource;
Azure::Core::Nullable<CopyStatusType> CopyStatus;
bool IsServerEncrypted = bool();
FileShareSmbProperties SmbProperties;
Azure::Core::Nullable<LeaseDurationType> LeaseDuration;
Azure::Core::Nullable<LeaseStateType> LeaseState;
Azure::Core::Nullable<LeaseStatusType> LeaseStatus;
};
using SetShareFilePropertiesResult = Details::FileSetHttpHeadersResult;
using ResizeFileResult = Details::FileSetHttpHeadersResult;
using SetShareFileMetadataResult = Details::FileSetMetadataResult;
@ -161,13 +225,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { names
struct DownloadShareFileToResult
{
Azure::Core::ETag ETag;
Core::DateTime LastModified;
int64_t ContentLength = 0;
int64_t FileSize;
Azure::Core::Http::Range ContentRange;
ShareFileHttpHeaders HttpHeaders;
Storage::Metadata Metadata;
bool IsServerEncrypted = false;
std::string RequestId;
DownloadShareFileDetails Details;
};
struct ForceCloseShareFileHandleResult

View File

@ -39,7 +39,7 @@ void FileShareGettingStarted()
{
std::cout << metadata.first << ":" << metadata.second << std::endl;
}
fileContent.resize(static_cast<std::size_t>(properties.ContentLength));
fileContent.resize(static_cast<std::size_t>(properties.FileSize));
fileClient.DownloadTo(reinterpret_cast<uint8_t*>(&fileContent[0]), fileContent.size());

View File

@ -287,7 +287,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}
auto newResponse = Download(newOptions);
if (eTag != newResponse->ETag)
if (eTag != newResponse->Details.ETag)
{
throw Azure::Core::RequestFailedException(
"File was changed during the download process.");
@ -300,7 +300,36 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
downloadResponse->BodyStream = std::make_unique<ReliableStream>(
std::move(downloadResponse->BodyStream), reliableStreamOptions, retryFunction);
}
return downloadResponse;
Models::DownloadShareFileResult ret;
ret.BodyStream = std::move(downloadResponse->BodyStream);
ret.ContentRange = std::move(downloadResponse->ContentRange);
ret.FileSize = downloadResponse->FileSize;
ret.TransactionalContentHash = std::move(downloadResponse->TransactionalContentHash);
ret.HttpHeaders = std::move(downloadResponse->HttpHeaders);
ret.Details.LastModified = std::move(downloadResponse->LastModified);
ret.Details.Metadata = std::move(downloadResponse->Metadata);
ret.Details.ETag = std::move(downloadResponse->ETag);
ret.Details.AcceptRanges = std::move(downloadResponse->AcceptRanges);
ret.Details.CopyCompletedOn = std::move(downloadResponse->CopyCompletedOn);
ret.Details.CopyStatusDescription = std::move(downloadResponse->CopyStatusDescription);
ret.Details.CopyId = std::move(downloadResponse->CopyId);
ret.Details.CopyProgress = std::move(downloadResponse->CopyProgress);
ret.Details.CopySource = std::move(downloadResponse->CopySource);
ret.Details.CopyStatus = std::move(downloadResponse->CopyStatus);
ret.Details.IsServerEncrypted = downloadResponse->IsServerEncrypted;
ret.Details.SmbProperties.Attributes
= Details::FileAttributesListFromString(downloadResponse->FileAttributes);
ret.Details.SmbProperties.CreatedOn = std::move(downloadResponse->FileCreatedOn);
ret.Details.SmbProperties.LastWrittenOn = std::move(downloadResponse->FileLastWrittenOn);
ret.Details.SmbProperties.ChangedOn = std::move(downloadResponse->FileChangedOn);
ret.Details.SmbProperties.PermissionKey = std::move(downloadResponse->FilePermissionKey);
ret.Details.SmbProperties.FileId = std::move(downloadResponse->FileId);
ret.Details.SmbProperties.ParentId = std::move(downloadResponse->FileParentId);
ret.Details.LeaseDuration = std::move(downloadResponse->LeaseDuration);
ret.Details.LeaseState = std::move(downloadResponse->LeaseState);
ret.Details.LeaseStatus = std::move(downloadResponse->LeaseStatus);
return Azure::Core::Response<Models::DownloadShareFileResult>(
std::move(ret), downloadResponse.ExtractRawResponse());
}
Azure::Core::Response<Models::StartCopyShareFileResult> ShareFileClient::StartCopy(
@ -380,8 +409,33 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
auto protocolLayerOptions = Details::ShareRestClient::File::GetPropertiesOptions();
protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId;
return Details::ShareRestClient::File::GetProperties(
auto result = Details::ShareRestClient::File::GetProperties(
m_shareFileUrl, *m_pipeline, options.Context, protocolLayerOptions);
Models::GetShareFilePropertiesResult ret;
ret.FileSize = result->ContentLength;
ret.HttpHeaders = std::move(result->HttpHeaders);
ret.LastModified = std::move(result->LastModified);
ret.Metadata = std::move(result->Metadata);
ret.ETag = std::move(result->ETag);
ret.CopyCompletedOn = std::move(result->CopyCompletedOn);
ret.CopyStatusDescription = std::move(result->CopyStatusDescription);
ret.CopyId = std::move(result->CopyId);
ret.CopyProgress = std::move(result->CopyProgress);
ret.CopySource = std::move(result->CopySource);
ret.CopyStatus = std::move(result->CopyStatus);
ret.IsServerEncrypted = result->IsServerEncrypted;
ret.SmbProperties.Attributes = Details::FileAttributesListFromString(result->FileAttributes);
ret.SmbProperties.CreatedOn = std::move(result->FileCreatedOn);
ret.SmbProperties.LastWrittenOn = std::move(result->FileLastWrittenOn);
ret.SmbProperties.ChangedOn = std::move(result->FileChangedOn);
ret.SmbProperties.PermissionKey = std::move(result->FilePermissionKey);
ret.SmbProperties.FileId = std::move(result->FileId);
ret.SmbProperties.ParentId = std::move(result->FileParentId);
ret.LeaseDuration = std::move(result->LeaseDuration);
ret.LeaseState = std::move(result->LeaseState);
ret.LeaseStatus = std::move(result->LeaseStatus);
return Azure::Core::Response<Models::GetShareFilePropertiesResult>(
std::move(ret), result.ExtractRawResponse());
}
Azure::Core::Response<Models::SetShareFilePropertiesResult> ShareFileClient::SetProperties(
@ -632,11 +686,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
auto returnTypeConverter
= [](Azure::Core::Response<Models::DownloadShareFileResult>& response) {
Models::DownloadShareFileToResult ret;
ret.ETag = std::move(response->ETag);
ret.LastModified = std::move(response->LastModified);
ret.FileSize = response->FileSize;
ret.HttpHeaders = std::move(response->HttpHeaders);
ret.Metadata = std::move(response->Metadata);
ret.IsServerEncrypted = response->IsServerEncrypted;
ret.Details = std::move(response->Details);
return Azure::Core::Response<Models::DownloadShareFileToResult>(
std::move(ret), response.ExtractRawResponse());
};
@ -676,7 +728,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
options.TransferOptions.ChunkSize,
options.TransferOptions.Concurrency,
downloadChunkFunc);
ret->ContentLength = fileRangeSize;
ret->ContentRange.Offset = firstChunkOffset;
ret->ContentRange.Length = fileRangeSize;
return ret;
}
@ -753,11 +806,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
auto returnTypeConverter
= [](Azure::Core::Response<Models::DownloadShareFileResult>& response) {
Models::DownloadShareFileToResult ret;
ret.ETag = std::move(response->ETag);
ret.LastModified = std::move(response->LastModified);
ret.FileSize = response->FileSize;
ret.HttpHeaders = std::move(response->HttpHeaders);
ret.Metadata = std::move(response->Metadata);
ret.IsServerEncrypted = response->IsServerEncrypted;
ret.Details = std::move(response->Details);
return Azure::Core::Response<Models::DownloadShareFileToResult>(
std::move(ret), response.ExtractRawResponse());
};
@ -794,7 +845,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
options.TransferOptions.ChunkSize,
options.TransferOptions.Concurrency,
downloadChunkFunc);
ret->ContentLength = fileRangeSize;
ret->ContentRange.Offset = firstChunkOffset;
ret->ContentRange.Length = fileRangeSize;
return ret;
}

View File

@ -453,19 +453,18 @@ namespace Azure { namespace Storage { namespace Test {
{
EXPECT_TRUE(shareClients.find(shareItem.Name) != shareClients.end());
properties = *shareClients.at(shareItem.Name).GetProperties();
EXPECT_EQ(
true, shareItem.Properties.AccessTier.HasValue() && properties.AccessTier.HasValue());
EXPECT_EQ(shareItem.Properties.AccessTier.GetValue(), properties.AccessTier.GetValue());
EXPECT_EQ(true, shareItem.Details.AccessTier.HasValue() && properties.AccessTier.HasValue());
EXPECT_EQ(shareItem.Details.AccessTier.GetValue(), properties.AccessTier.GetValue());
EXPECT_EQ(
true,
shareItem.Properties.AccessTierChangeTime.HasValue()
shareItem.Details.AccessTierChangeTime.HasValue()
&& properties.AccessTierChangeTime.HasValue());
EXPECT_EQ(
shareItem.Properties.AccessTierChangeTime.GetValue(),
shareItem.Details.AccessTierChangeTime.GetValue(),
properties.AccessTierChangeTime.GetValue());
EXPECT_EQ(
false,
shareItem.Properties.AccessTierTransitionState.HasValue()
shareItem.Details.AccessTierTransitionState.HasValue()
|| properties.AccessTierTransitionState.HasValue());
}
}
@ -491,9 +490,9 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_EQ(1U, shareItems.size());
EXPECT_EQ(
Files::Shares::Models::ShareAccessTier::Premium,
shareItems[0].Properties.AccessTier.GetValue());
EXPECT_FALSE(shareItems[0].Properties.AccessTierTransitionState.HasValue());
EXPECT_FALSE(shareItems[0].Properties.AccessTierChangeTime.HasValue());
shareItems[0].Details.AccessTier.GetValue());
EXPECT_FALSE(shareItems[0].Details.AccessTierTransitionState.HasValue());
EXPECT_FALSE(shareItems[0].Details.AccessTierChangeTime.HasValue());
auto setPropertiesOptions = Files::Shares::SetSharePropertiesOptions();
setPropertiesOptions.AccessTier = Files::Shares::Models::ShareAccessTier::Hot;

View File

@ -381,7 +381,7 @@ namespace Azure { namespace Storage { namespace Test {
result.first.end(),
[&name](const Files::Shares::Models::FileItem& item) { return item.Name == name; });
EXPECT_EQ(iter->Name, name);
EXPECT_EQ(1024, iter->Properties.ContentLength);
EXPECT_EQ(1024, iter->Details.ContentLength);
EXPECT_NE(result.first.end(), iter);
}
for (const auto& name : directoryNameSetB)

View File

@ -150,16 +150,19 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NO_THROW(client1.Create(1024, options1));
EXPECT_NO_THROW(client2.Create(1024, options2));
auto result1 = client1.GetProperties()->FilePermissionKey;
auto result2 = client2.GetProperties()->FilePermissionKey;
EXPECT_EQ(result1, result2);
auto result1 = client1.GetProperties()->SmbProperties.PermissionKey;
auto result2 = client2.GetProperties()->SmbProperties.PermissionKey;
EXPECT_TRUE(result1.HasValue());
EXPECT_TRUE(result2.HasValue());
EXPECT_EQ(result1.GetValue(), result2.GetValue());
auto client3 = m_fileShareDirectoryClient->GetFileClient(LowercaseRandomString());
Files::Shares::CreateShareFileOptions options3;
options3.SmbProperties.PermissionKey = result1;
EXPECT_NO_THROW(client3.Create(1024, options3));
auto result3 = client3.GetProperties()->FilePermissionKey;
EXPECT_EQ(result1, result3);
auto result3 = client3.GetProperties()->SmbProperties.PermissionKey;
EXPECT_TRUE(result3.HasValue());
EXPECT_EQ(result1.GetValue(), result3.GetValue());
}
{
@ -181,17 +184,20 @@ namespace Azure { namespace Storage { namespace Test {
options2.Permission = permission;
EXPECT_NO_THROW(client1.SetProperties(GetInterestingHttpHeaders(), properties, options1));
EXPECT_NO_THROW(client2.SetProperties(GetInterestingHttpHeaders(), properties, options2));
auto result1 = client1.GetProperties()->FilePermissionKey;
auto result2 = client1.GetProperties()->FilePermissionKey;
EXPECT_EQ(result1, result2);
auto result1 = client1.GetProperties()->SmbProperties.PermissionKey;
auto result2 = client1.GetProperties()->SmbProperties.PermissionKey;
EXPECT_TRUE(result1.HasValue());
EXPECT_TRUE(result2.HasValue());
EXPECT_EQ(result1.GetValue(), result2.GetValue());
auto client3 = m_fileShareDirectoryClient->GetFileClient(LowercaseRandomString());
Files::Shares::CreateShareFileOptions options3;
options3.SmbProperties.PermissionKey = result1;
std::string permissionKey;
EXPECT_NO_THROW(permissionKey = client3.Create(1024, options3)->FilePermissionKey);
auto result3 = client3.GetProperties()->FilePermissionKey;
EXPECT_EQ(permissionKey, result3);
auto result3 = client3.GetProperties()->SmbProperties.PermissionKey;
EXPECT_TRUE(result3.HasValue());
EXPECT_EQ(permissionKey, result3.GetValue());
}
}
@ -202,7 +208,7 @@ namespace Azure { namespace Storage { namespace Test {
| Files::Shares::Models::FileAttributes::NotContentIndexed;
properties.CreatedOn = std::chrono::system_clock::now();
properties.LastWrittenOn = std::chrono::system_clock::now();
properties.PermissionKey = m_fileClient->GetProperties()->FilePermissionKey;
properties.PermissionKey = m_fileClient->GetProperties()->SmbProperties.PermissionKey;
{
// Create directory with SmbProperties works
auto client1 = m_fileShareDirectoryClient->GetFileClient(LowercaseRandomString());
@ -216,9 +222,15 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NO_THROW(client2.Create(1024, options2));
auto directoryProperties1 = client1.GetProperties();
auto directoryProperties2 = client2.GetProperties();
EXPECT_EQ(directoryProperties2->FileCreatedOn, directoryProperties1->FileCreatedOn);
EXPECT_EQ(directoryProperties2->FileLastWrittenOn, directoryProperties1->FileLastWrittenOn);
EXPECT_EQ(directoryProperties2->FileAttributes, directoryProperties1->FileAttributes);
EXPECT_EQ(
directoryProperties2->SmbProperties.CreatedOn.GetValue(),
directoryProperties1->SmbProperties.CreatedOn.GetValue());
EXPECT_EQ(
directoryProperties2->SmbProperties.LastWrittenOn.GetValue(),
directoryProperties1->SmbProperties.LastWrittenOn.GetValue());
EXPECT_EQ(
directoryProperties2->SmbProperties.Attributes,
directoryProperties1->SmbProperties.Attributes);
}
{
@ -232,9 +244,15 @@ namespace Azure { namespace Storage { namespace Test {
EXPECT_NO_THROW(client2.SetProperties(GetInterestingHttpHeaders(), properties));
auto directoryProperties1 = client1.GetProperties();
auto directoryProperties2 = client2.GetProperties();
EXPECT_EQ(directoryProperties2->FileCreatedOn, directoryProperties1->FileCreatedOn);
EXPECT_EQ(directoryProperties2->FileLastWrittenOn, directoryProperties1->FileLastWrittenOn);
EXPECT_EQ(directoryProperties2->FileAttributes, directoryProperties1->FileAttributes);
EXPECT_EQ(
directoryProperties2->SmbProperties.CreatedOn.GetValue(),
directoryProperties1->SmbProperties.CreatedOn.GetValue());
EXPECT_EQ(
directoryProperties2->SmbProperties.LastWrittenOn.GetValue(),
directoryProperties1->SmbProperties.LastWrittenOn.GetValue());
EXPECT_EQ(
directoryProperties2->SmbProperties.Attributes,
directoryProperties1->SmbProperties.Attributes);
}
}
@ -305,7 +323,7 @@ namespace Azure { namespace Storage { namespace Test {
= fileClient.UploadFrom(fileContent.data(), static_cast<std::size_t>(fileSize), options);
auto properties = *fileClient.GetProperties();
EXPECT_EQ(properties.ContentLength, fileSize);
EXPECT_EQ(properties.FileSize, fileSize);
EXPECT_EQ(properties.Metadata, options.Metadata);
std::vector<uint8_t> downloadContent(static_cast<std::size_t>(fileSize), '\x00');
fileClient.DownloadTo(downloadContent.data(), static_cast<std::size_t>(fileSize));
@ -333,7 +351,7 @@ namespace Azure { namespace Storage { namespace Test {
auto res = fileClient.UploadFrom(tempFilename, options);
auto properties = *fileClient.GetProperties();
EXPECT_EQ(properties.ContentLength, fileSize);
EXPECT_EQ(properties.FileSize, fileSize);
EXPECT_EQ(properties.Metadata, options.Metadata);
std::vector<uint8_t> downloadContent(static_cast<std::size_t>(fileSize), '\x00');
fileClient.DownloadTo(downloadContent.data(), static_cast<std::size_t>(fileSize));
@ -425,8 +443,8 @@ namespace Azure { namespace Storage { namespace Test {
if (actualDownloadSize > 0)
{
auto res = m_fileClient->DownloadTo(downloadBuffer.data(), downloadBuffer.size(), options);
EXPECT_EQ(res->ContentLength, actualDownloadSize);
downloadBuffer.resize(static_cast<std::size_t>(res->ContentLength));
EXPECT_EQ(res->ContentRange.Length.GetValue(), actualDownloadSize);
downloadBuffer.resize(static_cast<std::size_t>(res->ContentRange.Length.GetValue()));
EXPECT_EQ(downloadBuffer, expectedData);
}
else
@ -494,7 +512,7 @@ namespace Azure { namespace Storage { namespace Test {
if (actualDownloadSize > 0)
{
auto res = m_fileClient->DownloadTo(tempFilename, options);
EXPECT_EQ(res->ContentLength, actualDownloadSize);
EXPECT_EQ(res->ContentRange.Length.GetValue(), actualDownloadSize);
EXPECT_EQ(ReadFile(tempFilename), expectedData);
}
else