Storage/Stg100/Remove Create File With Data feature (#6845)
* Remove Create File With Data * Fix build failure * Fix clang format
This commit is contained in:
parent
6fa588e08c
commit
72c2c981be
@ -1173,24 +1173,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
*/
|
||||
std::string ParentFileId;
|
||||
};
|
||||
/**
|
||||
* @brief SMB only, default value is New. New will forcefully add the ARCHIVE attribute flag
|
||||
* and alter the permissions specified in x-ms-file-permission to inherit missing permissions
|
||||
* from the parent. Restore will apply changes without further modification.
|
||||
*/
|
||||
class FilePropertySemantics final
|
||||
: public Core::_internal::ExtendableEnumeration<FilePropertySemantics> {
|
||||
public:
|
||||
/** Constructs a new FilePropertySemantics instance */
|
||||
FilePropertySemantics() = default;
|
||||
/** Constructs a new FilePropertySemantics from a string. */
|
||||
explicit FilePropertySemantics(std::string value) : ExtendableEnumeration(std::move(value)) {}
|
||||
|
||||
/** Constant value of type FilePropertySemantics: New */
|
||||
AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FilePropertySemantics New;
|
||||
/** Constant value of type FilePropertySemantics: Restore */
|
||||
AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FilePropertySemantics Restore;
|
||||
};
|
||||
/**
|
||||
* @brief NFS only. Type of the file or directory.
|
||||
*/
|
||||
@ -1692,19 +1674,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
* NFS only. Type of the file or directory.
|
||||
*/
|
||||
Nullable<Models::NfsFileType> NfsFileType;
|
||||
/**
|
||||
* If the file has an MD5 hash and the request is to read the full file, this response
|
||||
* header is returned so that the client can check for message content integrity. If the
|
||||
* request is to read a specified range and the 'x-ms-range-get-content-md5' is set to true,
|
||||
* then the request returns an MD5 hash for the range, as long as the range size is less
|
||||
* than or equal to 4 MB. If neither of these sets of conditions is true, then no value is
|
||||
* returned for the 'Content-MD5' header.
|
||||
*/
|
||||
Nullable<ContentHash> ContentMD5;
|
||||
/**
|
||||
* The number of bytes present in the response body.
|
||||
*/
|
||||
Nullable<std::int64_t> ContentLength;
|
||||
};
|
||||
} // namespace _detail
|
||||
/**
|
||||
@ -2756,7 +2725,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
Nullable<std::string> Owner;
|
||||
Nullable<std::string> Group;
|
||||
Nullable<std::string> FileMode;
|
||||
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
|
||||
};
|
||||
static Response<Models::_detail::CreateDirectoryResult> Create(
|
||||
Core::Http::_internal::HttpPipeline& pipeline,
|
||||
@ -2911,13 +2879,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
Nullable<std::string> Group;
|
||||
Nullable<std::string> FileMode;
|
||||
Nullable<Models::NfsFileType> NfsFileType;
|
||||
Nullable<std::vector<std::uint8_t>> ContentMD5;
|
||||
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
|
||||
};
|
||||
static Response<Models::_detail::CreateFileResult> Create(
|
||||
Core::Http::_internal::HttpPipeline& pipeline,
|
||||
const Core::Url& url,
|
||||
Core::IO::BodyStream& requestBody,
|
||||
const CreateFileOptions& options,
|
||||
const Core::Context& context);
|
||||
struct DownloadFileOptions final
|
||||
|
||||
@ -101,21 +101,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
const CreateFileOptions& options = CreateFileOptions(),
|
||||
const Azure::Core::Context& context = Azure::Core::Context()) const;
|
||||
|
||||
/**
|
||||
* @brief Creates the file with content. The content length must be smaller than fileSize.
|
||||
* @param fileSize Size of the file in bytes.
|
||||
* @param content A BodyStream containing the content to upload.
|
||||
* @param options Optional parameters to create this file.
|
||||
* @param context Context for cancelling long running operations.
|
||||
* @return Azure::Response<CreateFileResult> containing the information returned when
|
||||
* creating the file.
|
||||
*/
|
||||
Azure::Response<Models::CreateFileResult> Create(
|
||||
int64_t fileSize,
|
||||
Azure::Core::IO::BodyStream& content,
|
||||
const CreateFileOptions& options = CreateFileOptions(),
|
||||
const Azure::Core::Context& context = Azure::Core::Context()) const;
|
||||
|
||||
/**
|
||||
* @brief Deletes the file.
|
||||
* @param options Optional parameters to delete this file.
|
||||
|
||||
@ -609,17 +609,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
* The NFS related properties for the file.
|
||||
*/
|
||||
Models::FilePosixProperties PosixProperties;
|
||||
|
||||
/**
|
||||
* Optional, only applicable to SMB files.
|
||||
* How attributes and permissions should be set on the file.
|
||||
* New: automatically adds the ARCHIVE file attribute flag to the file and uses
|
||||
* Windows create file permissions semantics (ex: inherit from parent).
|
||||
* Restore: does not modify file attribute flag and uses Windows update file permissions
|
||||
* semantics. If Restore is specified, the file permission must also be provided or
|
||||
* PropertySemantics will default to New.
|
||||
*/
|
||||
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -936,17 +925,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
* The NFS related properties for the file.
|
||||
*/
|
||||
Models::FilePosixProperties PosixProperties;
|
||||
|
||||
/**
|
||||
* Optional, only applicable to SMB files.
|
||||
* How attributes and permissions should be set on the file.
|
||||
* New: automatically adds the ARCHIVE file attribute flag to the file and uses
|
||||
* Windows create file permissions semantics (ex: inherit from parent).
|
||||
* Restore: does not modify file attribute flag and uses Windows update file permissions
|
||||
* semantics. If Restore is specified, the file permission must also be provided or
|
||||
* PropertySemantics will default to New.
|
||||
*/
|
||||
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1356,17 +1334,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
*/
|
||||
Models::FilePosixProperties PosixProperties;
|
||||
|
||||
/**
|
||||
* Optional, only applicable to SMB files.
|
||||
* How attributes and permissions should be set on the file.
|
||||
* New: automatically adds the ARCHIVE file attribute flag to the file and uses
|
||||
* Windows create file permissions semantics (ex: inherit from parent).
|
||||
* Restore: does not modify file attribute flag and uses Windows update file permissions
|
||||
* semantics. If Restore is specified, the file permission must also be provided or
|
||||
* PropertySemantics will default to New.
|
||||
*/
|
||||
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
|
||||
|
||||
/**
|
||||
* @brief Options for parallel transfer.
|
||||
*/
|
||||
|
||||
@ -559,19 +559,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
* The NFS related properties for the file.
|
||||
*/
|
||||
FilePosixProperties PosixProperties;
|
||||
/**
|
||||
* If the file has an MD5 hash and the request is to read the full file, this response
|
||||
* header is returned so that the client can check for message content integrity. If the
|
||||
* request is to read a specified range and the 'x-ms-range-get-content-md5' is set to true,
|
||||
* then the request returns an MD5 hash for the range, as long as the range size is less
|
||||
* than or equal to 4 MB. If neither of these sets of conditions is true, then no value is
|
||||
* returned for the 'Content-MD5' header.
|
||||
*/
|
||||
Nullable<ContentHash> ContentMD5;
|
||||
/**
|
||||
* The number of bytes present in the response body.
|
||||
*/
|
||||
Nullable<std::int64_t> ContentLength;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
#include <azure/core/url.hpp>
|
||||
#include <azure/storage/common/crypt.hpp>
|
||||
#include <azure/storage/common/internal/xml_wrapper.hpp>
|
||||
#include <azure/storage/common/storage_common.hpp>
|
||||
#include <azure/storage/common/storage_exception.hpp>
|
||||
#include <azure/storage/files/shares/rest_client.hpp>
|
||||
|
||||
@ -186,8 +185,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
const FileAttributes FileAttributes::Offline("Offline");
|
||||
const FileAttributes FileAttributes::NotContentIndexed("NotContentIndexed");
|
||||
const FileAttributes FileAttributes::NoScrubData("NoScrubData");
|
||||
const FilePropertySemantics FilePropertySemantics::New("New");
|
||||
const FilePropertySemantics FilePropertySemantics::Restore("Restore");
|
||||
const NfsFileType NfsFileType::Regular("Regular");
|
||||
const NfsFileType NfsFileType::Directory("Directory");
|
||||
const NfsFileType NfsFileType::SymLink("SymLink");
|
||||
@ -2384,12 +2381,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
{
|
||||
request.SetHeader("x-ms-mode", options.FileMode.Value());
|
||||
}
|
||||
if (options.FilePropertySemantics.HasValue()
|
||||
&& !options.FilePropertySemantics.Value().ToString().empty())
|
||||
{
|
||||
request.SetHeader(
|
||||
"x-ms-file-property-semantics", options.FilePropertySemantics.Value().ToString());
|
||||
}
|
||||
auto pRawResponse = pipeline.Send(request, context);
|
||||
auto httpStatusCode = pRawResponse->GetStatusCode();
|
||||
if (httpStatusCode != Core::Http::HttpStatusCode::Created)
|
||||
@ -3507,11 +3498,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
Response<Models::_detail::CreateFileResult> FileClient::Create(
|
||||
Core::Http::_internal::HttpPipeline& pipeline,
|
||||
const Core::Url& url,
|
||||
Core::IO::BodyStream& requestBody,
|
||||
const CreateFileOptions& options,
|
||||
const Core::Context& context)
|
||||
{
|
||||
auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url, &requestBody);
|
||||
auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url);
|
||||
if (options.AllowTrailingDot.HasValue())
|
||||
{
|
||||
request.SetHeader(
|
||||
@ -3606,18 +3596,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
{
|
||||
request.SetHeader("x-ms-file-file-type", options.NfsFileType.Value().ToString());
|
||||
}
|
||||
if (options.ContentMD5.HasValue()
|
||||
&& !Core::Convert::Base64Encode(options.ContentMD5.Value()).empty())
|
||||
{
|
||||
request.SetHeader("Content-MD5", Core::Convert::Base64Encode(options.ContentMD5.Value()));
|
||||
}
|
||||
if (options.FilePropertySemantics.HasValue()
|
||||
&& !options.FilePropertySemantics.Value().ToString().empty())
|
||||
{
|
||||
request.SetHeader(
|
||||
"x-ms-file-property-semantics", options.FilePropertySemantics.Value().ToString());
|
||||
}
|
||||
request.SetHeader("Content-Length", std::to_string(requestBody.Length()));
|
||||
auto pRawResponse = pipeline.Send(request, context);
|
||||
auto httpStatusCode = pRawResponse->GetStatusCode();
|
||||
if (httpStatusCode != Core::Http::HttpStatusCode::Created)
|
||||
@ -3677,17 +3655,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
response.NfsFileType
|
||||
= Models::NfsFileType(pRawResponse->GetHeaders().at("x-ms-file-file-type"));
|
||||
}
|
||||
if (pRawResponse->GetHeaders().count("Content-MD5") != 0)
|
||||
{
|
||||
response.ContentMD5 = ContentHash();
|
||||
response.ContentMD5.Value().Value
|
||||
= Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("Content-MD5"));
|
||||
response.ContentMD5.Value().Algorithm = HashAlgorithm::Md5;
|
||||
}
|
||||
if (pRawResponse->GetHeaders().count("Content-Length") != 0)
|
||||
{
|
||||
response.ContentLength = std::stoll(pRawResponse->GetHeaders().at("Content-Length"));
|
||||
}
|
||||
return Response<Models::_detail::CreateFileResult>(
|
||||
std::move(response), std::move(pRawResponse));
|
||||
}
|
||||
|
||||
@ -201,7 +201,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
}
|
||||
protocolLayerOptions.Owner = options.PosixProperties.Owner;
|
||||
protocolLayerOptions.Group = options.PosixProperties.Group;
|
||||
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
|
||||
|
||||
auto result = _detail::DirectoryClient::Create(
|
||||
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);
|
||||
|
||||
@ -142,16 +142,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
int64_t fileSize,
|
||||
const CreateFileOptions& options,
|
||||
const Azure::Core::Context& context) const
|
||||
{
|
||||
Azure::Core::IO::_internal::NullBodyStream nullContent;
|
||||
return Create(fileSize, nullContent, options, context);
|
||||
}
|
||||
|
||||
Azure::Response<Models::CreateFileResult> ShareFileClient::Create(
|
||||
int64_t fileSize,
|
||||
Azure::Core::IO::BodyStream& content,
|
||||
const CreateFileOptions& options,
|
||||
const Azure::Core::Context& context) const
|
||||
{
|
||||
auto protocolLayerOptions = _detail::FileClient::CreateFileOptions();
|
||||
protocolLayerOptions.Metadata
|
||||
@ -220,10 +210,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
protocolLayerOptions.Owner = options.PosixProperties.Owner;
|
||||
protocolLayerOptions.Group = options.PosixProperties.Group;
|
||||
protocolLayerOptions.NfsFileType = options.PosixProperties.NfsFileType;
|
||||
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
|
||||
|
||||
auto result = _detail::FileClient::Create(
|
||||
*m_pipeline, m_shareFileUrl, content, protocolLayerOptions, context);
|
||||
auto result
|
||||
= _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
|
||||
Models::CreateFileResult ret;
|
||||
ret.Created = true;
|
||||
ret.ETag = std::move(result.Value.ETag);
|
||||
@ -238,8 +227,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
ret.PosixProperties.Owner = std::move(result.Value.Owner);
|
||||
ret.PosixProperties.Group = std::move(result.Value.Group);
|
||||
ret.PosixProperties.NfsFileType = std::move(result.Value.NfsFileType);
|
||||
ret.ContentMD5 = std::move(result.Value.ContentMD5);
|
||||
ret.ContentLength = std::move(result.Value.ContentLength);
|
||||
|
||||
return Azure::Response<Models::CreateFileResult>(std::move(ret), std::move(result.RawResponse));
|
||||
}
|
||||
@ -1245,11 +1232,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
protocolLayerOptions.Owner = options.PosixProperties.Owner;
|
||||
protocolLayerOptions.Group = options.PosixProperties.Group;
|
||||
protocolLayerOptions.NfsFileType = options.PosixProperties.NfsFileType;
|
||||
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
|
||||
|
||||
Azure::Core::IO::_internal::NullBodyStream nullContent;
|
||||
auto createResult = _detail::FileClient::Create(
|
||||
*m_pipeline, m_shareFileUrl, nullContent, protocolLayerOptions, context);
|
||||
auto createResult
|
||||
= _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
|
||||
|
||||
auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
|
||||
(void)chunkId;
|
||||
@ -1360,11 +1345,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
protocolLayerOptions.Owner = options.PosixProperties.Owner;
|
||||
protocolLayerOptions.Group = options.PosixProperties.Group;
|
||||
protocolLayerOptions.NfsFileType = options.PosixProperties.NfsFileType;
|
||||
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
|
||||
|
||||
Azure::Core::IO::_internal::NullBodyStream nullContent;
|
||||
auto createResult = _detail::FileClient::Create(
|
||||
*m_pipeline, m_shareFileUrl, nullContent, protocolLayerOptions, context);
|
||||
auto createResult
|
||||
= _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
|
||||
|
||||
auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
|
||||
(void)chunkId;
|
||||
|
||||
@ -239,6 +239,7 @@ directive:
|
||||
$.FilePermissionFormat["enum"] = ["sddl", "binary"];
|
||||
$.FileAttributes["required"] = true;
|
||||
delete $.EnableSmbDirectoryLease;
|
||||
delete $.FilePropertySemantics;
|
||||
- from: swagger-document
|
||||
where: $.definitions
|
||||
transform: >
|
||||
@ -749,6 +750,10 @@ directive:
|
||||
},
|
||||
"x-namespace" : "_detail"
|
||||
};
|
||||
- from: swagger-document
|
||||
where: $["x-ms-paths"]["/{shareName}/{directory}?restype=directory"].put.parameters
|
||||
transform: >
|
||||
$ = $.filter(p => !p["$ref"] || !p["$ref"].endsWith("#/parameters/FilePropertySemantics"));
|
||||
```
|
||||
|
||||
### DeleteDirectory
|
||||
@ -849,8 +854,8 @@ directive:
|
||||
$.headers["x-ms-owner"]["x-nullable"] = true;
|
||||
$.headers["x-ms-group"]["x-nullable"] = true;
|
||||
$.headers["x-ms-file-file-type"]["x-nullable"] = true;
|
||||
$.headers["Content-MD5"]["x-nullable"] = true;
|
||||
$.headers["Content-Length"]["x-nullable"] = true;
|
||||
delete $.headers["Content-MD5"];
|
||||
delete $.headers["Content-Length"];
|
||||
$.schema = {
|
||||
"type": "object",
|
||||
"x-ms-client-name": "CreateFileResult",
|
||||
@ -861,6 +866,10 @@ directive:
|
||||
},
|
||||
"x-namespace" : "_detail"
|
||||
};
|
||||
- from: swagger-document
|
||||
where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}"].put.parameters
|
||||
transform: >
|
||||
$ = $.filter(p => !(p["$ref"] && (p["$ref"].endsWith("#/parameters/ContentMD5") || p["$ref"].endsWith("#/parameters/FilePropertySemantics") || p["$ref"].endsWith("#/parameters/ContentLengthOptional") || p["$ref"].endsWith("#/parameters/OptionalBody"))));
|
||||
```
|
||||
|
||||
### GetFileProperties
|
||||
|
||||
@ -1448,28 +1448,4 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
properties.PosixProperties.NfsFileType.Value(),
|
||||
Files::Shares::Models::NfsFileType::Directory);
|
||||
}
|
||||
|
||||
TEST_F(FileShareDirectoryClientTest, CreateWithFilePropertySemantics)
|
||||
{
|
||||
|
||||
auto directoryClient1
|
||||
= m_shareClient->GetRootDirectoryClient().GetSubdirectoryClient(LowercaseRandomString());
|
||||
|
||||
Files::Shares::CreateDirectoryOptions createOptions;
|
||||
|
||||
// New
|
||||
createOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::New;
|
||||
Files::Shares::Models::CreateDirectoryResult createResult;
|
||||
EXPECT_NO_THROW(createResult = directoryClient1.Create(createOptions).Value);
|
||||
|
||||
// Restore
|
||||
auto directoryClient2
|
||||
= m_shareClient->GetRootDirectoryClient().GetSubdirectoryClient(LowercaseRandomString());
|
||||
std::string permission = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-"
|
||||
"2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;"
|
||||
"0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)";
|
||||
createOptions.DirectoryPermission = permission;
|
||||
createOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::Restore;
|
||||
EXPECT_NO_THROW(createResult = directoryClient2.Create(createOptions).Value);
|
||||
}
|
||||
}}} // namespace Azure::Storage::Test
|
||||
|
||||
@ -2608,77 +2608,4 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
destFileClient = shareClient.GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
EXPECT_THROW(destFileClient.StartCopy(sourceClient.GetUrl(), copyOptions), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(FileShareFileClientTest, CreateWithContent)
|
||||
{
|
||||
size_t fileSize = 512;
|
||||
std::vector<uint8_t> content(RandomBuffer(fileSize));
|
||||
auto memBodyStream = Core::IO::MemoryBodyStream(content);
|
||||
|
||||
auto fileClient
|
||||
= m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
|
||||
// Create with content
|
||||
Files::Shares::Models::CreateFileResult createResult;
|
||||
EXPECT_NO_THROW(createResult = fileClient.Create(fileSize, memBodyStream).Value);
|
||||
EXPECT_TRUE(createResult.ContentLength.HasValue());
|
||||
EXPECT_TRUE(createResult.ContentMD5.HasValue());
|
||||
}
|
||||
|
||||
TEST_F(FileShareFileClientTest, CreateWithFilePropertySemantics)
|
||||
{
|
||||
size_t fileSize = 512;
|
||||
std::string permission = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-"
|
||||
"2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;"
|
||||
"0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)";
|
||||
|
||||
{
|
||||
Files::Shares::CreateFileOptions createOptions;
|
||||
Files::Shares::Models::CreateFileResult createResult;
|
||||
// New
|
||||
auto fileClient1
|
||||
= m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
createOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::New;
|
||||
EXPECT_NO_THROW(createResult = fileClient1.Create(fileSize, createOptions).Value);
|
||||
EXPECT_EQ(
|
||||
Files::Shares::Models::FileAttributes::Archive, createResult.SmbProperties.Attributes);
|
||||
|
||||
// Restore
|
||||
auto fileClient2
|
||||
= m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
|
||||
createOptions.Permission = permission;
|
||||
createOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::Restore;
|
||||
EXPECT_NO_THROW(createResult = fileClient2.Create(fileSize, createOptions).Value);
|
||||
EXPECT_EQ(Files::Shares::Models::FileAttributes::None, createResult.SmbProperties.Attributes);
|
||||
}
|
||||
|
||||
{
|
||||
const auto blobContent = RandomBuffer(static_cast<size_t>(512));
|
||||
|
||||
const std::string tempFileName = RandomString();
|
||||
WriteFile(
|
||||
tempFileName,
|
||||
std::vector<uint8_t>(
|
||||
blobContent.begin(), blobContent.begin() + static_cast<size_t>(fileSize)));
|
||||
|
||||
Files::Shares::UploadFileFromOptions uploadOptions;
|
||||
|
||||
// New
|
||||
auto fileClient1
|
||||
= m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
uploadOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::New;
|
||||
EXPECT_NO_THROW(fileClient1.UploadFrom(blobContent.data(), fileSize, uploadOptions));
|
||||
fileClient1 = m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
EXPECT_NO_THROW(fileClient1.UploadFrom(tempFileName, uploadOptions));
|
||||
|
||||
// Restore
|
||||
auto fileClient2
|
||||
= m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
uploadOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::Restore;
|
||||
EXPECT_NO_THROW(fileClient2.UploadFrom(blobContent.data(), fileSize, uploadOptions));
|
||||
fileClient1 = m_shareClient->GetRootDirectoryClient().GetFileClient(LowercaseRandomString());
|
||||
EXPECT_NO_THROW(fileClient2.UploadFrom(tempFileName, uploadOptions));
|
||||
}
|
||||
}
|
||||
}}} // namespace Azure::Storage::Test
|
||||
|
||||
Loading…
Reference in New Issue
Block a user