Skip to content

Commit 72c2c98

Browse files
authored
Storage/Stg100/Remove Create File With Data feature (#6845)
* Remove Create File With Data * Fix build failure * Fix clang format
1 parent 6fa588e commit 72c2c98

File tree

10 files changed

+18
-253
lines changed

10 files changed

+18
-253
lines changed

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,24 +1173,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
11731173
*/
11741174
std::string ParentFileId;
11751175
};
1176-
/**
1177-
* @brief SMB only, default value is New. New will forcefully add the ARCHIVE attribute flag
1178-
* and alter the permissions specified in x-ms-file-permission to inherit missing permissions
1179-
* from the parent. Restore will apply changes without further modification.
1180-
*/
1181-
class FilePropertySemantics final
1182-
: public Core::_internal::ExtendableEnumeration<FilePropertySemantics> {
1183-
public:
1184-
/** Constructs a new FilePropertySemantics instance */
1185-
FilePropertySemantics() = default;
1186-
/** Constructs a new FilePropertySemantics from a string. */
1187-
explicit FilePropertySemantics(std::string value) : ExtendableEnumeration(std::move(value)) {}
1188-
1189-
/** Constant value of type FilePropertySemantics: New */
1190-
AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FilePropertySemantics New;
1191-
/** Constant value of type FilePropertySemantics: Restore */
1192-
AZ_STORAGE_FILES_SHARES_DLLEXPORT const static FilePropertySemantics Restore;
1193-
};
11941176
/**
11951177
* @brief NFS only. Type of the file or directory.
11961178
*/
@@ -1692,19 +1674,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
16921674
* NFS only. Type of the file or directory.
16931675
*/
16941676
Nullable<Models::NfsFileType> NfsFileType;
1695-
/**
1696-
* If the file has an MD5 hash and the request is to read the full file, this response
1697-
* header is returned so that the client can check for message content integrity. If the
1698-
* request is to read a specified range and the 'x-ms-range-get-content-md5' is set to true,
1699-
* then the request returns an MD5 hash for the range, as long as the range size is less
1700-
* than or equal to 4 MB. If neither of these sets of conditions is true, then no value is
1701-
* returned for the 'Content-MD5' header.
1702-
*/
1703-
Nullable<ContentHash> ContentMD5;
1704-
/**
1705-
* The number of bytes present in the response body.
1706-
*/
1707-
Nullable<std::int64_t> ContentLength;
17081677
};
17091678
} // namespace _detail
17101679
/**
@@ -2756,7 +2725,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
27562725
Nullable<std::string> Owner;
27572726
Nullable<std::string> Group;
27582727
Nullable<std::string> FileMode;
2759-
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
27602728
};
27612729
static Response<Models::_detail::CreateDirectoryResult> Create(
27622730
Core::Http::_internal::HttpPipeline& pipeline,
@@ -2911,13 +2879,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
29112879
Nullable<std::string> Group;
29122880
Nullable<std::string> FileMode;
29132881
Nullable<Models::NfsFileType> NfsFileType;
2914-
Nullable<std::vector<std::uint8_t>> ContentMD5;
2915-
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
29162882
};
29172883
static Response<Models::_detail::CreateFileResult> Create(
29182884
Core::Http::_internal::HttpPipeline& pipeline,
29192885
const Core::Url& url,
2920-
Core::IO::BodyStream& requestBody,
29212886
const CreateFileOptions& options,
29222887
const Core::Context& context);
29232888
struct DownloadFileOptions final

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
101101
const CreateFileOptions& options = CreateFileOptions(),
102102
const Azure::Core::Context& context = Azure::Core::Context()) const;
103103

104-
/**
105-
* @brief Creates the file with content. The content length must be smaller than fileSize.
106-
* @param fileSize Size of the file in bytes.
107-
* @param content A BodyStream containing the content to upload.
108-
* @param options Optional parameters to create this file.
109-
* @param context Context for cancelling long running operations.
110-
* @return Azure::Response<CreateFileResult> containing the information returned when
111-
* creating the file.
112-
*/
113-
Azure::Response<Models::CreateFileResult> Create(
114-
int64_t fileSize,
115-
Azure::Core::IO::BodyStream& content,
116-
const CreateFileOptions& options = CreateFileOptions(),
117-
const Azure::Core::Context& context = Azure::Core::Context()) const;
118-
119104
/**
120105
* @brief Deletes the file.
121106
* @param options Optional parameters to delete this file.

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -609,17 +609,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
609609
* The NFS related properties for the file.
610610
*/
611611
Models::FilePosixProperties PosixProperties;
612-
613-
/**
614-
* Optional, only applicable to SMB files.
615-
* How attributes and permissions should be set on the file.
616-
* New: automatically adds the ARCHIVE file attribute flag to the file and uses
617-
* Windows create file permissions semantics (ex: inherit from parent).
618-
* Restore: does not modify file attribute flag and uses Windows update file permissions
619-
* semantics. If Restore is specified, the file permission must also be provided or
620-
* PropertySemantics will default to New.
621-
*/
622-
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
623612
};
624613

625614
/**
@@ -936,17 +925,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
936925
* The NFS related properties for the file.
937926
*/
938927
Models::FilePosixProperties PosixProperties;
939-
940-
/**
941-
* Optional, only applicable to SMB files.
942-
* How attributes and permissions should be set on the file.
943-
* New: automatically adds the ARCHIVE file attribute flag to the file and uses
944-
* Windows create file permissions semantics (ex: inherit from parent).
945-
* Restore: does not modify file attribute flag and uses Windows update file permissions
946-
* semantics. If Restore is specified, the file permission must also be provided or
947-
* PropertySemantics will default to New.
948-
*/
949-
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
950928
};
951929

952930
/**
@@ -1356,17 +1334,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
13561334
*/
13571335
Models::FilePosixProperties PosixProperties;
13581336

1359-
/**
1360-
* Optional, only applicable to SMB files.
1361-
* How attributes and permissions should be set on the file.
1362-
* New: automatically adds the ARCHIVE file attribute flag to the file and uses
1363-
* Windows create file permissions semantics (ex: inherit from parent).
1364-
* Restore: does not modify file attribute flag and uses Windows update file permissions
1365-
* semantics. If Restore is specified, the file permission must also be provided or
1366-
* PropertySemantics will default to New.
1367-
*/
1368-
Nullable<Models::FilePropertySemantics> FilePropertySemantics;
1369-
13701337
/**
13711338
* @brief Options for parallel transfer.
13721339
*/

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -559,19 +559,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
559559
* The NFS related properties for the file.
560560
*/
561561
FilePosixProperties PosixProperties;
562-
/**
563-
* If the file has an MD5 hash and the request is to read the full file, this response
564-
* header is returned so that the client can check for message content integrity. If the
565-
* request is to read a specified range and the 'x-ms-range-get-content-md5' is set to true,
566-
* then the request returns an MD5 hash for the range, as long as the range size is less
567-
* than or equal to 4 MB. If neither of these sets of conditions is true, then no value is
568-
* returned for the 'Content-MD5' header.
569-
*/
570-
Nullable<ContentHash> ContentMD5;
571-
/**
572-
* The number of bytes present in the response body.
573-
*/
574-
Nullable<std::int64_t> ContentLength;
575562
};
576563

577564
/**

sdk/storage/azure-storage-files-shares/src/rest_client.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <azure/core/url.hpp>
1818
#include <azure/storage/common/crypt.hpp>
1919
#include <azure/storage/common/internal/xml_wrapper.hpp>
20-
#include <azure/storage/common/storage_common.hpp>
2120
#include <azure/storage/common/storage_exception.hpp>
2221
#include <azure/storage/files/shares/rest_client.hpp>
2322

@@ -186,8 +185,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
186185
const FileAttributes FileAttributes::Offline("Offline");
187186
const FileAttributes FileAttributes::NotContentIndexed("NotContentIndexed");
188187
const FileAttributes FileAttributes::NoScrubData("NoScrubData");
189-
const FilePropertySemantics FilePropertySemantics::New("New");
190-
const FilePropertySemantics FilePropertySemantics::Restore("Restore");
191188
const NfsFileType NfsFileType::Regular("Regular");
192189
const NfsFileType NfsFileType::Directory("Directory");
193190
const NfsFileType NfsFileType::SymLink("SymLink");
@@ -2384,12 +2381,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
23842381
{
23852382
request.SetHeader("x-ms-mode", options.FileMode.Value());
23862383
}
2387-
if (options.FilePropertySemantics.HasValue()
2388-
&& !options.FilePropertySemantics.Value().ToString().empty())
2389-
{
2390-
request.SetHeader(
2391-
"x-ms-file-property-semantics", options.FilePropertySemantics.Value().ToString());
2392-
}
23932384
auto pRawResponse = pipeline.Send(request, context);
23942385
auto httpStatusCode = pRawResponse->GetStatusCode();
23952386
if (httpStatusCode != Core::Http::HttpStatusCode::Created)
@@ -3507,11 +3498,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
35073498
Response<Models::_detail::CreateFileResult> FileClient::Create(
35083499
Core::Http::_internal::HttpPipeline& pipeline,
35093500
const Core::Url& url,
3510-
Core::IO::BodyStream& requestBody,
35113501
const CreateFileOptions& options,
35123502
const Core::Context& context)
35133503
{
3514-
auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url, &requestBody);
3504+
auto request = Core::Http::Request(Core::Http::HttpMethod::Put, url);
35153505
if (options.AllowTrailingDot.HasValue())
35163506
{
35173507
request.SetHeader(
@@ -3606,18 +3596,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
36063596
{
36073597
request.SetHeader("x-ms-file-file-type", options.NfsFileType.Value().ToString());
36083598
}
3609-
if (options.ContentMD5.HasValue()
3610-
&& !Core::Convert::Base64Encode(options.ContentMD5.Value()).empty())
3611-
{
3612-
request.SetHeader("Content-MD5", Core::Convert::Base64Encode(options.ContentMD5.Value()));
3613-
}
3614-
if (options.FilePropertySemantics.HasValue()
3615-
&& !options.FilePropertySemantics.Value().ToString().empty())
3616-
{
3617-
request.SetHeader(
3618-
"x-ms-file-property-semantics", options.FilePropertySemantics.Value().ToString());
3619-
}
3620-
request.SetHeader("Content-Length", std::to_string(requestBody.Length()));
36213599
auto pRawResponse = pipeline.Send(request, context);
36223600
auto httpStatusCode = pRawResponse->GetStatusCode();
36233601
if (httpStatusCode != Core::Http::HttpStatusCode::Created)
@@ -3677,17 +3655,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
36773655
response.NfsFileType
36783656
= Models::NfsFileType(pRawResponse->GetHeaders().at("x-ms-file-file-type"));
36793657
}
3680-
if (pRawResponse->GetHeaders().count("Content-MD5") != 0)
3681-
{
3682-
response.ContentMD5 = ContentHash();
3683-
response.ContentMD5.Value().Value
3684-
= Core::Convert::Base64Decode(pRawResponse->GetHeaders().at("Content-MD5"));
3685-
response.ContentMD5.Value().Algorithm = HashAlgorithm::Md5;
3686-
}
3687-
if (pRawResponse->GetHeaders().count("Content-Length") != 0)
3688-
{
3689-
response.ContentLength = std::stoll(pRawResponse->GetHeaders().at("Content-Length"));
3690-
}
36913658
return Response<Models::_detail::CreateFileResult>(
36923659
std::move(response), std::move(pRawResponse));
36933660
}

sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
201201
}
202202
protocolLayerOptions.Owner = options.PosixProperties.Owner;
203203
protocolLayerOptions.Group = options.PosixProperties.Group;
204-
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
205204

206205
auto result = _detail::DirectoryClient::Create(
207206
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);

sdk/storage/azure-storage-files-shares/src/share_file_client.cpp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
142142
int64_t fileSize,
143143
const CreateFileOptions& options,
144144
const Azure::Core::Context& context) const
145-
{
146-
Azure::Core::IO::_internal::NullBodyStream nullContent;
147-
return Create(fileSize, nullContent, options, context);
148-
}
149-
150-
Azure::Response<Models::CreateFileResult> ShareFileClient::Create(
151-
int64_t fileSize,
152-
Azure::Core::IO::BodyStream& content,
153-
const CreateFileOptions& options,
154-
const Azure::Core::Context& context) const
155145
{
156146
auto protocolLayerOptions = _detail::FileClient::CreateFileOptions();
157147
protocolLayerOptions.Metadata
@@ -220,10 +210,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
220210
protocolLayerOptions.Owner = options.PosixProperties.Owner;
221211
protocolLayerOptions.Group = options.PosixProperties.Group;
222212
protocolLayerOptions.NfsFileType = options.PosixProperties.NfsFileType;
223-
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
224213

225-
auto result = _detail::FileClient::Create(
226-
*m_pipeline, m_shareFileUrl, content, protocolLayerOptions, context);
214+
auto result
215+
= _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
227216
Models::CreateFileResult ret;
228217
ret.Created = true;
229218
ret.ETag = std::move(result.Value.ETag);
@@ -238,8 +227,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
238227
ret.PosixProperties.Owner = std::move(result.Value.Owner);
239228
ret.PosixProperties.Group = std::move(result.Value.Group);
240229
ret.PosixProperties.NfsFileType = std::move(result.Value.NfsFileType);
241-
ret.ContentMD5 = std::move(result.Value.ContentMD5);
242-
ret.ContentLength = std::move(result.Value.ContentLength);
243230

244231
return Azure::Response<Models::CreateFileResult>(std::move(ret), std::move(result.RawResponse));
245232
}
@@ -1245,11 +1232,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
12451232
protocolLayerOptions.Owner = options.PosixProperties.Owner;
12461233
protocolLayerOptions.Group = options.PosixProperties.Group;
12471234
protocolLayerOptions.NfsFileType = options.PosixProperties.NfsFileType;
1248-
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
12491235

1250-
Azure::Core::IO::_internal::NullBodyStream nullContent;
1251-
auto createResult = _detail::FileClient::Create(
1252-
*m_pipeline, m_shareFileUrl, nullContent, protocolLayerOptions, context);
1236+
auto createResult
1237+
= _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
12531238

12541239
auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
12551240
(void)chunkId;
@@ -1360,11 +1345,9 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
13601345
protocolLayerOptions.Owner = options.PosixProperties.Owner;
13611346
protocolLayerOptions.Group = options.PosixProperties.Group;
13621347
protocolLayerOptions.NfsFileType = options.PosixProperties.NfsFileType;
1363-
protocolLayerOptions.FilePropertySemantics = options.FilePropertySemantics;
13641348

1365-
Azure::Core::IO::_internal::NullBodyStream nullContent;
1366-
auto createResult = _detail::FileClient::Create(
1367-
*m_pipeline, m_shareFileUrl, nullContent, protocolLayerOptions, context);
1349+
auto createResult
1350+
= _detail::FileClient::Create(*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
13681351

13691352
auto uploadPageFunc = [&](int64_t offset, int64_t length, int64_t chunkId, int64_t numChunks) {
13701353
(void)chunkId;

sdk/storage/azure-storage-files-shares/swagger/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ directive:
239239
$.FilePermissionFormat["enum"] = ["sddl", "binary"];
240240
$.FileAttributes["required"] = true;
241241
delete $.EnableSmbDirectoryLease;
242+
delete $.FilePropertySemantics;
242243
- from: swagger-document
243244
where: $.definitions
244245
transform: >
@@ -749,6 +750,10 @@ directive:
749750
},
750751
"x-namespace" : "_detail"
751752
};
753+
- from: swagger-document
754+
where: $["x-ms-paths"]["/{shareName}/{directory}?restype=directory"].put.parameters
755+
transform: >
756+
$ = $.filter(p => !p["$ref"] || !p["$ref"].endsWith("#/parameters/FilePropertySemantics"));
752757
```
753758
754759
### DeleteDirectory
@@ -849,8 +854,8 @@ directive:
849854
$.headers["x-ms-owner"]["x-nullable"] = true;
850855
$.headers["x-ms-group"]["x-nullable"] = true;
851856
$.headers["x-ms-file-file-type"]["x-nullable"] = true;
852-
$.headers["Content-MD5"]["x-nullable"] = true;
853-
$.headers["Content-Length"]["x-nullable"] = true;
857+
delete $.headers["Content-MD5"];
858+
delete $.headers["Content-Length"];
854859
$.schema = {
855860
"type": "object",
856861
"x-ms-client-name": "CreateFileResult",
@@ -861,6 +866,10 @@ directive:
861866
},
862867
"x-namespace" : "_detail"
863868
};
869+
- from: swagger-document
870+
where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}"].put.parameters
871+
transform: >
872+
$ = $.filter(p => !(p["$ref"] && (p["$ref"].endsWith("#/parameters/ContentMD5") || p["$ref"].endsWith("#/parameters/FilePropertySemantics") || p["$ref"].endsWith("#/parameters/ContentLengthOptional") || p["$ref"].endsWith("#/parameters/OptionalBody"))));
864873
```
865874
866875
### GetFileProperties

sdk/storage/azure-storage-files-shares/test/ut/share_directory_client_test.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,28 +1448,4 @@ namespace Azure { namespace Storage { namespace Test {
14481448
properties.PosixProperties.NfsFileType.Value(),
14491449
Files::Shares::Models::NfsFileType::Directory);
14501450
}
1451-
1452-
TEST_F(FileShareDirectoryClientTest, CreateWithFilePropertySemantics)
1453-
{
1454-
1455-
auto directoryClient1
1456-
= m_shareClient->GetRootDirectoryClient().GetSubdirectoryClient(LowercaseRandomString());
1457-
1458-
Files::Shares::CreateDirectoryOptions createOptions;
1459-
1460-
// New
1461-
createOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::New;
1462-
Files::Shares::Models::CreateDirectoryResult createResult;
1463-
EXPECT_NO_THROW(createResult = directoryClient1.Create(createOptions).Value);
1464-
1465-
// Restore
1466-
auto directoryClient2
1467-
= m_shareClient->GetRootDirectoryClient().GetSubdirectoryClient(LowercaseRandomString());
1468-
std::string permission = "O:S-1-5-21-2127521184-1604012920-1887927527-21560751G:S-1-5-21-"
1469-
"2127521184-1604012920-1887927527-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;"
1470-
"0x1200a9;;;S-1-5-21-397955417-626881126-188441444-3053964)";
1471-
createOptions.DirectoryPermission = permission;
1472-
createOptions.FilePropertySemantics = Files::Shares::Models::FilePropertySemantics::Restore;
1473-
EXPECT_NO_THROW(createResult = directoryClient2.Create(createOptions).Value);
1474-
}
14751451
}}} // namespace Azure::Storage::Test

0 commit comments

Comments
 (0)