| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | |
|
| | 7 | | #pragma warning disable SA1402 // File may only contain a single type |
| | 8 | |
|
| | 9 | | namespace Azure.Storage.Files.Shares.Models |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Properties for a file. |
| | 13 | | /// </summary> |
| | 14 | | public class ShareFileProperties |
| | 15 | | { |
| | 16 | | /// <summary> |
| | 17 | | /// The internal RawStorageFileProperties |
| | 18 | | /// </summary> |
| | 19 | | internal RawStorageFileProperties _rawStorageFileProperties; |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// The DateTimeOffset when the file was last modified. |
| | 23 | | /// </summary> |
| 4 | 24 | | public DateTimeOffset LastModified => _rawStorageFileProperties.LastModified; |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// A set of name-value pairs associated with this file as user-defined metadata. |
| | 28 | | /// </summary> |
| 10 | 29 | | public IDictionary<string, string> Metadata => _rawStorageFileProperties.Metadata; |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// The size of the file in bytes. |
| | 33 | | /// </summary> |
| 0 | 34 | | public long ContentLength => _rawStorageFileProperties.ContentLength; |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// The content type specified for the file. The default content type is 'application/octet-stream' |
| | 38 | | /// </summary> |
| 8 | 39 | | public string ContentType => _rawStorageFileProperties.ContentType; |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// The ETag contains a value that you can use to perform operations conditionally, in quotes. |
| | 43 | | /// </summary> |
| 26 | 44 | | public ETag ETag => _rawStorageFileProperties.ETag; |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// If the Content-MD5 header has been set for the file, the Content-MD5 response header is returned so that the |
| | 48 | | /// </summary> |
| | 49 | | #pragma warning disable CA1819 // Properties should not return arrays |
| 4 | 50 | | public byte[] ContentHash => _rawStorageFileProperties.ContentHash; |
| | 51 | | #pragma warning restore CA1819 // Properties should not return arrays |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// If the Content-Encoding request header has previously been set for the file, the Content-Encoding value is r |
| | 55 | | /// </summary> |
| 10 | 56 | | public IEnumerable<string> ContentEncoding => _rawStorageFileProperties.ContentEncoding; |
| | 57 | |
|
| | 58 | | /// <summary> |
| | 59 | | /// If the Cache-Control request header has previously been set for the file, the Cache-Control value is returne |
| | 60 | | /// </summary> |
| 6 | 61 | | public string CacheControl => _rawStorageFileProperties.CacheControl; |
| | 62 | |
|
| | 63 | | /// <summary> |
| | 64 | | /// Returns the value that was specified for the 'x-ms-content-disposition' header and specifies how to process |
| | 65 | | /// </summary> |
| 6 | 66 | | public string ContentDisposition => _rawStorageFileProperties.ContentDisposition; |
| | 67 | |
|
| | 68 | | /// <summary> |
| | 69 | | /// Returns the value that was specified for the Content-Language request header. |
| | 70 | | /// </summary> |
| 10 | 71 | | public IEnumerable<string> ContentLanguage => _rawStorageFileProperties.ContentLanguage; |
| | 72 | |
|
| | 73 | | /// <summary> |
| | 74 | | /// Conclusion time of the last attempted Copy File operation where this file was the destination file. This val |
| | 75 | | /// </summary> |
| 2 | 76 | | public DateTimeOffset CopyCompletedOn => _rawStorageFileProperties.CopyCompletionTime; |
| | 77 | |
|
| | 78 | | /// <summary> |
| | 79 | | /// Only appears when x-ms-copy-status is failed or pending. Describes cause of fatal or non-fatal copy operatio |
| | 80 | | /// </summary> |
| 2 | 81 | | public string CopyStatusDescription => _rawStorageFileProperties.CopyStatusDescription; |
| | 82 | |
|
| | 83 | | /// <summary> |
| | 84 | | /// String identifier for the last attempted Copy File operation where this file was the destination file. |
| | 85 | | /// </summary> |
| 2 | 86 | | public string CopyId => _rawStorageFileProperties.CopyId; |
| | 87 | |
|
| | 88 | | /// <summary> |
| | 89 | | /// Contains the number of bytes copied and the total bytes in the source in the last attempted Copy File operat |
| | 90 | | /// </summary> |
| 2 | 91 | | public string CopyProgress => _rawStorageFileProperties.CopyProgress; |
| | 92 | |
|
| | 93 | | /// <summary> |
| | 94 | | /// URL up to 2KB in length that specifies the source file used in the last attempted Copy File operation where |
| | 95 | | /// </summary> |
| 2 | 96 | | public string CopySource => _rawStorageFileProperties.CopySource; |
| | 97 | |
|
| | 98 | | /// <summary> |
| | 99 | | /// State of the copy operation identified by 'x-ms-copy-id'. |
| | 100 | | /// </summary> |
| 4 | 101 | | public CopyStatus CopyStatus => _rawStorageFileProperties.CopyStatus; |
| | 102 | |
|
| | 103 | | /// <summary> |
| | 104 | | /// The value of this header is set to true if the file data and application metadata are completely encrypted u |
| | 105 | | /// </summary> |
| 4 | 106 | | public bool IsServerEncrypted => _rawStorageFileProperties.IsServerEncrypted; |
| | 107 | |
|
| | 108 | | /// <summary> |
| | 109 | | /// The SMB properties for the file |
| | 110 | | /// </summary> |
| 90 | 111 | | public FileSmbProperties SmbProperties { get; set; } |
| | 112 | |
|
| | 113 | | /// <summary> |
| | 114 | | /// When a file is leased, specifies whether the lease is of infinite or fixed duration. |
| | 115 | | /// </summary> |
| 2 | 116 | | public ShareLeaseDuration LeaseDuration => _rawStorageFileProperties.LeaseDuration; |
| | 117 | |
|
| | 118 | | /// <summary> |
| | 119 | | /// Lease state of the file. |
| | 120 | | /// </summary> |
| 2 | 121 | | public ShareLeaseState LeaseState => _rawStorageFileProperties.LeaseState; |
| | 122 | |
|
| | 123 | | /// <summary> |
| | 124 | | /// The current lease status of the file. |
| | 125 | | /// </summary> |
| 2 | 126 | | public ShareLeaseStatus LeaseStatus => _rawStorageFileProperties.LeaseStatus; |
| | 127 | |
|
| 74 | 128 | | internal ShareFileProperties(RawStorageFileProperties rawStorageFileProperties) |
| | 129 | | { |
| 74 | 130 | | _rawStorageFileProperties = rawStorageFileProperties; |
| 74 | 131 | | SmbProperties = new FileSmbProperties(rawStorageFileProperties); |
| 74 | 132 | | } |
| | 133 | | } |
| | 134 | |
|
| | 135 | | /// <summary> |
| | 136 | | /// FilesModelFactory provides utilities for mocking. |
| | 137 | | /// </summary> |
| | 138 | | public static partial class FilesModelFactory |
| | 139 | | { |
| | 140 | | /// <summary> |
| | 141 | | /// Creates a new StorageFileProperties instance for mocking. |
| | 142 | | /// </summary> |
| | 143 | | public static ShareFileProperties StorageFileProperties( |
| | 144 | | DateTimeOffset lastModified, |
| | 145 | | IDictionary<string, string> metadata, |
| | 146 | | long contentLength, |
| | 147 | | string contentType, |
| | 148 | | ETag eTag, |
| | 149 | | byte[] contentHash, |
| | 150 | | IEnumerable<string> contentEncoding, |
| | 151 | | string cacheControl, |
| | 152 | | string contentDisposition, |
| | 153 | | IEnumerable<string> contentLanguage, |
| | 154 | | DateTimeOffset copyCompletedOn, |
| | 155 | | string copyStatusDescription, |
| | 156 | | string copyId, |
| | 157 | | string copyProgress, |
| | 158 | | string copySource, |
| | 159 | | CopyStatus copyStatus, |
| | 160 | | bool isServerEncrypted, |
| | 161 | | string fileAttributes, |
| | 162 | | DateTimeOffset fileCreationTime, |
| | 163 | | DateTimeOffset fileLastWriteTime, |
| | 164 | | DateTimeOffset fileChangeTime, |
| | 165 | | string filePermissionKey, |
| | 166 | | string fileId, |
| | 167 | | string fileParentId |
| | 168 | | ) => new ShareFileProperties(new RawStorageFileProperties() |
| | 169 | | { |
| | 170 | | LastModified = lastModified, |
| | 171 | | Metadata = metadata, |
| | 172 | | ContentLength = contentLength, |
| | 173 | | ContentType = contentType, |
| | 174 | | ETag = eTag, |
| | 175 | | ContentHash = contentHash, |
| | 176 | | ContentEncoding = contentEncoding, |
| | 177 | | CacheControl = cacheControl, |
| | 178 | | ContentDisposition = contentDisposition, |
| | 179 | | ContentLanguage = contentLanguage, |
| | 180 | | CopyCompletionTime = copyCompletedOn, |
| | 181 | | CopyStatusDescription = copyStatusDescription, |
| | 182 | | CopyId = copyId, |
| | 183 | | CopyProgress = copyProgress, |
| | 184 | | CopySource = copySource, |
| | 185 | | CopyStatus = copyStatus, |
| | 186 | | IsServerEncrypted = isServerEncrypted, |
| | 187 | | FileAttributes = fileAttributes, |
| | 188 | | FilePermissionKey = filePermissionKey, |
| | 189 | | FileCreationTime = fileCreationTime, |
| | 190 | | FileLastWriteTime = fileLastWriteTime, |
| | 191 | | FileChangeTime = fileChangeTime, |
| | 192 | | FileId = fileId, |
| | 193 | | FileParentId = fileParentId |
| | 194 | | }); |
| | 195 | | } |
| | 196 | | } |