Skip to content

Commit 5e408c4

Browse files
authored
Create File with Data (Azure#50552)
1 parent a6c4936 commit 5e408c4

13 files changed

+611
-5
lines changed

sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.net8.0.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,9 @@ public static partial class FilesModelFactory
584584
public static Azure.Storage.Files.Shares.Models.ShareFileDownloadDetails StorageFileDownloadProperties(System.DateTimeOffset lastModified, System.Collections.Generic.IDictionary<string, string> metadata, string contentType, string contentRange, Azure.ETag eTag, System.Collections.Generic.IEnumerable<string> contentEncoding, string cacheControl, string contentDisposition, System.Collections.Generic.IEnumerable<string> contentLanguage, string acceptRanges, System.DateTimeOffset copyCompletedOn, string copyStatusDescription, string copyId, string copyProgress, System.Uri copySource, Azure.Storage.Files.Shares.Models.CopyStatus copyStatus, byte[] fileContentHash, bool isServiceEncrypted) { throw null; }
585585
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
586586
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, bool isServerEncrypted, string filePermissionKey, string fileAttributes, System.DateTimeOffset fileCreationTime, System.DateTimeOffset fileLastWriteTime, System.DateTimeOffset fileChangeTime, string fileId, string fileParentId) { throw null; }
587-
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag = default(Azure.ETag), System.DateTimeOffset lastModified = default(System.DateTimeOffset), bool isServerEncrypted = false, string filePermissionKey = null, string fileAttributes = null, System.DateTimeOffset fileCreationTime = default(System.DateTimeOffset), System.DateTimeOffset fileLastWriteTime = default(System.DateTimeOffset), System.DateTimeOffset fileChangeTime = default(System.DateTimeOffset), string fileId = null, string fileParentId = null, Azure.Storage.Files.Shares.Models.NfsFileMode nfsFileMode = null, string owner = null, string group = null, Azure.Storage.Files.Shares.Models.NfsFileType nfsFileType = default(Azure.Storage.Files.Shares.Models.NfsFileType)) { throw null; }
587+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
588+
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, bool isServerEncrypted, string filePermissionKey, string fileAttributes, System.DateTimeOffset fileCreationTime, System.DateTimeOffset fileLastWriteTime, System.DateTimeOffset fileChangeTime, string fileId, string fileParentId, Azure.Storage.Files.Shares.Models.NfsFileMode nfsFileMode, string owner, string group, Azure.Storage.Files.Shares.Models.NfsFileType nfsFileType) { throw null; }
589+
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag = default(Azure.ETag), System.DateTimeOffset lastModified = default(System.DateTimeOffset), bool isServerEncrypted = false, string filePermissionKey = null, string fileAttributes = null, System.DateTimeOffset fileCreationTime = default(System.DateTimeOffset), System.DateTimeOffset fileLastWriteTime = default(System.DateTimeOffset), System.DateTimeOffset fileChangeTime = default(System.DateTimeOffset), string fileId = null, string fileParentId = null, Azure.Storage.Files.Shares.Models.NfsFileMode nfsFileMode = null, string owner = null, string group = null, Azure.Storage.Files.Shares.Models.NfsFileType nfsFileType = default(Azure.Storage.Files.Shares.Models.NfsFileType), byte[] contentHash = null) { throw null; }
588590
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
589591
public static Azure.Storage.Files.Shares.Models.ShareFileItem StorageFileItem(bool isDirectory, string name, long? fileSize) { throw null; }
590592
public static Azure.Storage.Files.Shares.Models.ShareFileProperties StorageFileProperties(System.DateTimeOffset lastModified = default(System.DateTimeOffset), System.Collections.Generic.IDictionary<string, string> metadata = null, long contentLength = (long)0, string contentType = null, Azure.ETag eTag = default(Azure.ETag), byte[] contentHash = null, System.Collections.Generic.IEnumerable<string> contentEncoding = null, string cacheControl = null, string contentDisposition = null, System.Collections.Generic.IEnumerable<string> contentLanguage = null, System.DateTimeOffset copyCompletedOn = default(System.DateTimeOffset), string copyStatusDescription = null, string copyId = null, string copyProgress = null, string copySource = null, Azure.Storage.Files.Shares.Models.CopyStatus copyStatus = Azure.Storage.Files.Shares.Models.CopyStatus.Pending, bool isServerEncrypted = false, Azure.Storage.Files.Shares.Models.FileSmbProperties smbProperties = null, Azure.Storage.Files.Shares.Models.FilePosixProperties posixProperties = null) { throw null; }
@@ -755,6 +757,7 @@ public ShareDirectoryCreateOptions() { }
755757
public Azure.Storage.Files.Shares.Models.ShareFilePermission FilePermission { get { throw null; } set { } }
756758
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } set { } }
757759
public Azure.Storage.Files.Shares.Models.FilePosixProperties PosixProperties { get { throw null; } set { } }
760+
public Azure.Storage.Files.Shares.Models.FilePropertySemantics? PropertySemantics { get { throw null; } set { } }
758761
public Azure.Storage.Files.Shares.Models.FileSmbProperties SmbProperties { get { throw null; } set { } }
759762
}
760763
public partial class ShareDirectoryGetFilesAndDirectoriesOptions
@@ -907,11 +910,15 @@ public ShareFileCopyOptions() { }
907910
public partial class ShareFileCreateOptions
908911
{
909912
public ShareFileCreateOptions() { }
913+
public System.IO.Stream Content { get { throw null; } set { } }
910914
public Azure.Storage.Files.Shares.Models.ShareFilePermission FilePermission { get { throw null; } set { } }
911915
public Azure.Storage.Files.Shares.Models.ShareFileHttpHeaders HttpHeaders { get { throw null; } set { } }
912916
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } set { } }
913917
public Azure.Storage.Files.Shares.Models.FilePosixProperties PosixProperties { get { throw null; } set { } }
918+
public System.IProgress<long> ProgressHandler { get { throw null; } set { } }
919+
public Azure.Storage.Files.Shares.Models.FilePropertySemantics? PropertySemantics { get { throw null; } set { } }
914920
public Azure.Storage.Files.Shares.Models.FileSmbProperties SmbProperties { get { throw null; } set { } }
921+
public Azure.Storage.UploadTransferValidationOptions TransferValidation { get { throw null; } set { } }
915922
}
916923
public partial class ShareFileCreateSymbolicLinkOptions
917924
{
@@ -1021,6 +1028,7 @@ public ShareFileHttpHeaders() { }
10211028
public partial class ShareFileInfo
10221029
{
10231030
internal ShareFileInfo() { }
1031+
public byte[] ContentHash { get { throw null; } }
10241032
public Azure.ETag ETag { get { throw null; } }
10251033
public bool IsServerEncrypted { get { throw null; } }
10261034
public System.DateTimeOffset LastModified { get { throw null; } }

sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.netstandard2.0.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,9 @@ public static partial class FilesModelFactory
584584
public static Azure.Storage.Files.Shares.Models.ShareFileDownloadDetails StorageFileDownloadProperties(System.DateTimeOffset lastModified, System.Collections.Generic.IDictionary<string, string> metadata, string contentType, string contentRange, Azure.ETag eTag, System.Collections.Generic.IEnumerable<string> contentEncoding, string cacheControl, string contentDisposition, System.Collections.Generic.IEnumerable<string> contentLanguage, string acceptRanges, System.DateTimeOffset copyCompletedOn, string copyStatusDescription, string copyId, string copyProgress, System.Uri copySource, Azure.Storage.Files.Shares.Models.CopyStatus copyStatus, byte[] fileContentHash, bool isServiceEncrypted) { throw null; }
585585
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
586586
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, bool isServerEncrypted, string filePermissionKey, string fileAttributes, System.DateTimeOffset fileCreationTime, System.DateTimeOffset fileLastWriteTime, System.DateTimeOffset fileChangeTime, string fileId, string fileParentId) { throw null; }
587-
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag = default(Azure.ETag), System.DateTimeOffset lastModified = default(System.DateTimeOffset), bool isServerEncrypted = false, string filePermissionKey = null, string fileAttributes = null, System.DateTimeOffset fileCreationTime = default(System.DateTimeOffset), System.DateTimeOffset fileLastWriteTime = default(System.DateTimeOffset), System.DateTimeOffset fileChangeTime = default(System.DateTimeOffset), string fileId = null, string fileParentId = null, Azure.Storage.Files.Shares.Models.NfsFileMode nfsFileMode = null, string owner = null, string group = null, Azure.Storage.Files.Shares.Models.NfsFileType nfsFileType = default(Azure.Storage.Files.Shares.Models.NfsFileType)) { throw null; }
587+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
588+
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, bool isServerEncrypted, string filePermissionKey, string fileAttributes, System.DateTimeOffset fileCreationTime, System.DateTimeOffset fileLastWriteTime, System.DateTimeOffset fileChangeTime, string fileId, string fileParentId, Azure.Storage.Files.Shares.Models.NfsFileMode nfsFileMode, string owner, string group, Azure.Storage.Files.Shares.Models.NfsFileType nfsFileType) { throw null; }
589+
public static Azure.Storage.Files.Shares.Models.ShareFileInfo StorageFileInfo(Azure.ETag eTag = default(Azure.ETag), System.DateTimeOffset lastModified = default(System.DateTimeOffset), bool isServerEncrypted = false, string filePermissionKey = null, string fileAttributes = null, System.DateTimeOffset fileCreationTime = default(System.DateTimeOffset), System.DateTimeOffset fileLastWriteTime = default(System.DateTimeOffset), System.DateTimeOffset fileChangeTime = default(System.DateTimeOffset), string fileId = null, string fileParentId = null, Azure.Storage.Files.Shares.Models.NfsFileMode nfsFileMode = null, string owner = null, string group = null, Azure.Storage.Files.Shares.Models.NfsFileType nfsFileType = default(Azure.Storage.Files.Shares.Models.NfsFileType), byte[] contentHash = null) { throw null; }
588590
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
589591
public static Azure.Storage.Files.Shares.Models.ShareFileItem StorageFileItem(bool isDirectory, string name, long? fileSize) { throw null; }
590592
public static Azure.Storage.Files.Shares.Models.ShareFileProperties StorageFileProperties(System.DateTimeOffset lastModified = default(System.DateTimeOffset), System.Collections.Generic.IDictionary<string, string> metadata = null, long contentLength = (long)0, string contentType = null, Azure.ETag eTag = default(Azure.ETag), byte[] contentHash = null, System.Collections.Generic.IEnumerable<string> contentEncoding = null, string cacheControl = null, string contentDisposition = null, System.Collections.Generic.IEnumerable<string> contentLanguage = null, System.DateTimeOffset copyCompletedOn = default(System.DateTimeOffset), string copyStatusDescription = null, string copyId = null, string copyProgress = null, string copySource = null, Azure.Storage.Files.Shares.Models.CopyStatus copyStatus = Azure.Storage.Files.Shares.Models.CopyStatus.Pending, bool isServerEncrypted = false, Azure.Storage.Files.Shares.Models.FileSmbProperties smbProperties = null, Azure.Storage.Files.Shares.Models.FilePosixProperties posixProperties = null) { throw null; }
@@ -755,6 +757,7 @@ public ShareDirectoryCreateOptions() { }
755757
public Azure.Storage.Files.Shares.Models.ShareFilePermission FilePermission { get { throw null; } set { } }
756758
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } set { } }
757759
public Azure.Storage.Files.Shares.Models.FilePosixProperties PosixProperties { get { throw null; } set { } }
760+
public Azure.Storage.Files.Shares.Models.FilePropertySemantics? PropertySemantics { get { throw null; } set { } }
758761
public Azure.Storage.Files.Shares.Models.FileSmbProperties SmbProperties { get { throw null; } set { } }
759762
}
760763
public partial class ShareDirectoryGetFilesAndDirectoriesOptions
@@ -907,11 +910,15 @@ public ShareFileCopyOptions() { }
907910
public partial class ShareFileCreateOptions
908911
{
909912
public ShareFileCreateOptions() { }
913+
public System.IO.Stream Content { get { throw null; } set { } }
910914
public Azure.Storage.Files.Shares.Models.ShareFilePermission FilePermission { get { throw null; } set { } }
911915
public Azure.Storage.Files.Shares.Models.ShareFileHttpHeaders HttpHeaders { get { throw null; } set { } }
912916
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } set { } }
913917
public Azure.Storage.Files.Shares.Models.FilePosixProperties PosixProperties { get { throw null; } set { } }
918+
public System.IProgress<long> ProgressHandler { get { throw null; } set { } }
919+
public Azure.Storage.Files.Shares.Models.FilePropertySemantics? PropertySemantics { get { throw null; } set { } }
914920
public Azure.Storage.Files.Shares.Models.FileSmbProperties SmbProperties { get { throw null; } set { } }
921+
public Azure.Storage.UploadTransferValidationOptions TransferValidation { get { throw null; } set { } }
915922
}
916923
public partial class ShareFileCreateSymbolicLinkOptions
917924
{
@@ -1021,6 +1028,7 @@ public ShareFileHttpHeaders() { }
10211028
public partial class ShareFileInfo
10221029
{
10231030
internal ShareFileInfo() { }
1031+
public byte[] ContentHash { get { throw null; } }
10241032
public Azure.ETag ETag { get { throw null; } }
10251033
public bool IsServerEncrypted { get { throw null; } }
10261034
public System.DateTimeOffset LastModified { get { throw null; } }

sdk/storage/Azure.Storage.Files.Shares/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.Files.Shares",
5-
"Tag": "net/storage/Azure.Storage.Files.Shares_c83f0406a0"
5+
"Tag": "net/storage/Azure.Storage.Files.Shares_d79a8fcc69"
66
}

sdk/storage/Azure.Storage.Files.Shares/src/Models/ShareDirectoryCreateOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,15 @@ public class ShareDirectoryCreateOptions
3232
/// </summary>
3333
/// </summary>
3434
public FilePosixProperties PosixProperties { get; set; }
35+
36+
/// <summary>
37+
/// Optional, only applicable to SMB directories.
38+
/// How attributes and permissions should be set on the file.
39+
/// New: automatically adds the ARCHIVE file attribute flag to the file and uses
40+
/// Windows create file permissions semantics (ex: inherit from parent).
41+
/// Restore: does not modify file attribute flag and uses Windows update file permissions semantics.
42+
/// If Restore is specified, the file permission must also be provided, otherwise PropertySemantics will default to New.
43+
/// </summary>
44+
public FilePropertySemantics? PropertySemantics { get; set; }
3545
}
3646
}

sdk/storage/Azure.Storage.Files.Shares/src/Models/ShareFileCreateOptions.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System;
5+
using System.IO;
46
using Metadata = System.Collections.Generic.IDictionary<string, string>;
57

68
namespace Azure.Storage.Files.Shares.Models
@@ -36,5 +38,33 @@ public class ShareFileCreateOptions
3638
/// Note that this property is only applicable to files created in NFS shares.
3739
/// </summary>
3840
public FilePosixProperties PosixProperties { get; set; }
41+
42+
/// <summary>
43+
/// Optional, only applicable to SMB files.
44+
/// How attributes and permissions should be set on the file.
45+
/// New: automatically adds the ARCHIVE file attribute flag to the file and uses
46+
/// Windows create file permissions semantics (ex: inherit from parent).
47+
/// Restore: does not modify file attribute flag and uses Windows update file permissions semantics.
48+
/// If Restore is specified, the file permission must also be provided or PropertySemantics will default to New.
49+
/// </summary>
50+
public FilePropertySemantics? PropertySemantics { get; set; }
51+
52+
/// <summary>
53+
/// Optional, valid for version 2026-02-06 and later.
54+
/// The content to upload to the file when it is created. Must be less than or equal to 4 MiB in size.
55+
/// </summary>
56+
public Stream Content { get; set; }
57+
58+
/// <summary>
59+
/// Optional, only valid if Content is specified. <see cref="IProgress{Long}"/> to provide
60+
/// progress updates about data transfers.
61+
/// </summary>
62+
public IProgress<long> ProgressHandler { get; set; }
63+
64+
/// <summary>
65+
/// Optional, only valid if Content is specified. Override settings for this client'
66+
/// <see cref="ShareClientOptions.TransferValidation"/> settings hashing on uploads.
67+
/// </summary>
68+
public UploadTransferValidationOptions TransferValidation { get; set; }
3969
}
4070
}

sdk/storage/Azure.Storage.Files.Shares/src/Models/ShareFileInfo.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ public class ShareFileInfo
4242
/// </summary>
4343
public FilePosixProperties PosixProperties { get; internal set; }
4444

45+
/// <summary>
46+
/// Content Hash of the file. This value will only be populated if the file was created with data.
47+
/// </summary>
48+
#pragma warning disable CA1819 // Properties should not return arrays
49+
public byte[] ContentHash { get; internal set; }
50+
#pragma warning restore CA1819 // Properties should not return arrays
51+
4552
/// <summary>
4653
/// Constructor.
4754
/// </summary>
@@ -70,7 +77,52 @@ public static ShareFileInfo StorageFileInfo(
7077
NfsFileMode nfsFileMode = default,
7178
string owner = default,
7279
string group = default,
73-
NfsFileType nfsFileType = default)
80+
NfsFileType nfsFileType = default,
81+
byte[] contentHash = default)
82+
=> new ShareFileInfo
83+
{
84+
ETag = eTag,
85+
LastModified = lastModified,
86+
IsServerEncrypted = isServerEncrypted,
87+
SmbProperties = new FileSmbProperties
88+
{
89+
FileAttributes = ShareModelExtensions.ToFileAttributes(fileAttributes),
90+
FilePermissionKey = filePermissionKey,
91+
FileCreatedOn = fileCreationTime,
92+
FileLastWrittenOn = fileLastWriteTime,
93+
FileChangedOn = fileChangeTime,
94+
FileId = fileId,
95+
ParentId = fileParentId
96+
},
97+
PosixProperties = new FilePosixProperties
98+
{
99+
FileMode = nfsFileMode,
100+
Owner = owner,
101+
Group = group,
102+
FileType = nfsFileType,
103+
},
104+
ContentHash = contentHash
105+
};
106+
107+
/// <summary>
108+
/// Creates a new StorageFileInfo instance for mocking.
109+
/// </summary>
110+
[EditorBrowsable(EditorBrowsableState.Never)]
111+
public static ShareFileInfo StorageFileInfo(
112+
ETag eTag,
113+
DateTimeOffset lastModified,
114+
bool isServerEncrypted,
115+
string filePermissionKey,
116+
string fileAttributes,
117+
DateTimeOffset fileCreationTime,
118+
DateTimeOffset fileLastWriteTime,
119+
DateTimeOffset fileChangeTime,
120+
string fileId,
121+
string fileParentId,
122+
NfsFileMode nfsFileMode,
123+
string owner,
124+
string group,
125+
NfsFileType nfsFileType)
74126
=> new ShareFileInfo
75127
{
76128
ETag = eTag,

0 commit comments

Comments
 (0)