diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp index 1eb5d5aa1..750d28818 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp @@ -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 { - 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 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 ContentMD5; - /** - * The number of bytes present in the response body. - */ - Nullable ContentLength; }; } // namespace _detail /** @@ -2756,7 +2725,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable Owner; Nullable Group; Nullable FileMode; - Nullable FilePropertySemantics; }; static Response Create( Core::Http::_internal::HttpPipeline& pipeline, @@ -2911,13 +2879,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Nullable Group; Nullable FileMode; Nullable NfsFileType; - Nullable> ContentMD5; - Nullable FilePropertySemantics; }; static Response Create( Core::Http::_internal::HttpPipeline& pipeline, const Core::Url& url, - Core::IO::BodyStream& requestBody, const CreateFileOptions& options, const Core::Context& context); struct DownloadFileOptions final diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp index 7307eb805..94026ef92 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp @@ -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 containing the information returned when - * creating the file. - */ - Azure::Response 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. diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp index 741c96a97..fd264e6a1 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp @@ -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 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 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 FilePropertySemantics; - /** * @brief Options for parallel transfer. */ diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp index 52d8e1206..9535f9e16 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp @@ -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 ContentMD5; - /** - * The number of bytes present in the response body. - */ - Nullable ContentLength; }; /** diff --git a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp index d3ef4d93c..72b11fcfb 100644 --- a/sdk/storage/azure-storage-files-shares/src/rest_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/rest_client.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -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 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( std::move(response), std::move(pRawResponse)); } diff --git a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp index 884f684fb..852a78822 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp @@ -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); diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index d19ac1336..572ac0332 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -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 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(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; diff --git a/sdk/storage/azure-storage-files-shares/swagger/README.md b/sdk/storage/azure-storage-files-shares/swagger/README.md index a415ea2cf..95ca2423e 100644 --- a/sdk/storage/azure-storage-files-shares/swagger/README.md +++ b/sdk/storage/azure-storage-files-shares/swagger/README.md @@ -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 diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp index d09124af0..baf611596 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp @@ -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 diff --git a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp index ea1aea364..78bacb26c 100644 --- a/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp @@ -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 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(512)); - - const std::string tempFileName = RandomString(); - WriteFile( - tempFileName, - std::vector( - blobContent.begin(), blobContent.begin() + static_cast(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