< Summary

Class:Azure.Storage.Blobs.Models.BlobDownloadDetails
Assembly:Azure.Storage.Blobs
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\Models\BlobInfo.cs
Covered lines:25
Uncovered lines:4
Coverable lines:29
Total lines:506
Line coverage:86.2% (25 of 29)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_LastModified()-100%100%
get_Metadata()-100%100%
get_ContentRange()-100%100%
get_ETag()-100%100%
get_ContentEncoding()-100%100%
get_CacheControl()-0%100%
get_ContentDisposition()-100%100%
get_ContentLanguage()-100%100%
get_BlobSequenceNumber()-0%100%
get_CopyCompletedOn()-100%100%
get_CopyStatusDescription()-100%100%
get_CopyId()-100%100%
get_CopyProgress()-100%100%
get_CopySource()-0%100%
get_CopyStatus()-100%100%
get_LeaseDuration()-100%100%
get_LeaseState()-100%100%
get_LeaseStatus()-100%100%
get_AcceptRanges()-100%100%
get_BlobCommittedBlockCount()-0%100%
get_IsServerEncrypted()-100%100%
get_EncryptionKeySha256()-100%100%
get_EncryptionScope()-100%100%
get_BlobContentHash()-100%100%
get_TagCount()-100%100%
get_VersionId()-100%100%
get_IsSealed()-100%100%
get_ObjectReplicationSourceProperties()-100%100%
get_ObjectReplicationDestinationPolicyId()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\Models\BlobInfo.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.ComponentModel;
 7using System.IO;
 8using Azure.Storage.Blobs.Models;
 9using Azure.Storage.Shared;
 10
 11#pragma warning disable SA1402  // File may only contain a single type
 12
 13namespace Azure.Storage.Blobs.Models
 14{
 15    /// <summary>
 16    /// BlobInfo
 17    /// </summary>
 18    public partial class BlobInfo
 19    {
 20        /// <summary>
 21        /// The current sequence number for a page blob. This header is not
 22        /// returned for block blobs or append blobs.
 23        /// </summary>
 24        public long BlobSequenceNumber { get; internal set; }
 25
 26        /// <summary>
 27        /// The versionId of the blob version that was created.
 28        /// If null, a new blob version was not created.
 29        /// </summary>
 30        public string VersionId { get; internal set; }
 31    }
 32
 33    /// <summary>
 34    /// The details and Content returned from downloading a blob
 35    /// </summary>
 36    public partial class BlobDownloadInfo : IDisposable, IDownloadedContent
 37    {
 38        /// <summary>
 39        /// Internal flattened property representation
 40        /// </summary>
 41        internal FlattenedDownloadProperties _flattened;
 42
 43        /// <summary>
 44        /// The blob's type.
 45        /// </summary>
 46        public BlobType BlobType => _flattened.BlobType;
 47
 48        /// <summary>
 49        /// The number of bytes present in the response body.
 50        /// </summary>
 51        public long ContentLength => _flattened.ContentLength;
 52
 53        /// <summary>
 54        /// Content
 55        /// </summary>
 56        public Stream Content => _flattened.Content;
 57
 58        /// <summary>
 59        /// The media type of the body of the response. For Download Blob this is 'application/octet-stream'
 60        /// </summary>
 61        public string ContentType => _flattened.ContentType;
 62
 63        /// <summary>
 64        /// If the blob has an MD5 hash and this operation is to read the full blob, this response header is returned so
 65        /// </summary>
 66#pragma warning disable CA1819 // Properties should not return arrays
 67        public byte[] ContentHash => _flattened.ContentHash;
 68#pragma warning restore CA1819 // Properties should not return arrays
 69
 70        /// <summary>
 71        /// Details returned when downloading a Blob
 72        /// </summary>
 73        public BlobDownloadDetails Details { get; private set; }
 74
 75        /// <summary>
 76        /// Creates a new DownloadInfo backed by FlattenedDownloadProperties
 77        /// </summary>
 78        /// <param name="flattened">The FlattenedDownloadProperties returned with the request</param>
 79        internal BlobDownloadInfo(FlattenedDownloadProperties flattened)
 80        {
 81            _flattened = flattened;
 82            Details = new BlobDownloadDetails() {
 83                LastModified = flattened.LastModified,
 84                Metadata = flattened.Metadata,
 85                ContentRange = flattened.ContentRange,
 86                ETag = flattened.ETag,
 87                ContentEncoding = flattened.ContentEncoding,
 88                CacheControl = flattened.CacheControl,
 89                ContentDisposition = flattened.ContentDisposition,
 90                ContentLanguage = flattened.ContentLanguage,
 91                BlobSequenceNumber = flattened.BlobSequenceNumber,
 92                CopyCompletedOn = flattened.CopyCompletionTime,
 93                CopyStatusDescription = flattened.CopyStatusDescription,
 94                CopyId = flattened.CopyId,
 95                CopyProgress = flattened.CopyProgress,
 96                CopySource = flattened.CopySource,
 97                CopyStatus = flattened.CopyStatus,
 98                LeaseDuration = flattened.LeaseDuration,
 99                LeaseState = flattened.LeaseState,
 100                LeaseStatus = flattened.LeaseStatus,
 101                AcceptRanges = flattened.AcceptRanges,
 102                BlobCommittedBlockCount = flattened.BlobCommittedBlockCount,
 103                IsServerEncrypted = flattened.IsServerEncrypted,
 104                EncryptionKeySha256 = flattened.EncryptionKeySha256,
 105                EncryptionScope = flattened.EncryptionScope,
 106                BlobContentHash = flattened.BlobContentHash,
 107                TagCount = flattened.TagCount,
 108                VersionId = flattened.VersionId,
 109                IsSealed = flattened.IsSealed,
 110                ObjectReplicationSourceProperties =
 111                    flattened.ObjectReplicationRules?.Count > 0
 112                    ? BlobExtensions.ParseObjectReplicationIds(flattened.ObjectReplicationRules)
 113                    : null,
 114                ObjectReplicationDestinationPolicyId = flattened.ObjectReplicationPolicyId
 115            };
 116        }
 117
 118        /// <summary>
 119        /// Disposes the BlobDownloadInfo by calling Dispose on the underlying Content stream.
 120        /// </summary>
 121        public void Dispose()
 122        {
 123            Content?.Dispose();
 124            GC.SuppressFinalize(this);
 125        }
 126    }
 127
 128    /// <summary>
 129    /// Details returned when downloading a Blob
 130    /// </summary>
 131    public partial class BlobDownloadDetails
 132    {
 133        /// <summary>
 134        /// Returns the date and time the container was last modified. Any operation that modifies the blob, including a
 135        /// </summary>
 368136        public DateTimeOffset LastModified { get; internal set; }
 137
 138        /// <summary>
 139        /// x-ms-meta
 140        /// </summary>
 368141        public IDictionary<string, string> Metadata { get; internal set; }
 142
 143        /// <summary>
 144        /// Indicates the range of bytes returned in the event that the client requested a subset of the blob by setting
 145        /// </summary>
 2138146        public string ContentRange { get; internal set; }
 147
 148        /// <summary>
 149        /// The ETag contains a value that you can use to perform operations conditionally. If the request version is 20
 150        /// </summary>
 1238151        public ETag ETag { get; internal set; }
 152
 153        /// <summary>
 154        /// This header returns the value that was specified for the Content-Encoding request header
 155        /// </summary>
 368156        public string ContentEncoding { get; internal set; }
 157
 158        /// <summary>
 159        /// This header is returned if it was previously specified for the blob.
 160        /// </summary>
 0161        public string CacheControl { get; internal set; }
 162
 163        /// <summary>
 164        /// This header returns the value that was specified for the 'x-ms-blob-content-disposition' header. The Content
 165        /// </summary>
 368166        public string ContentDisposition { get; internal set; }
 167
 168        /// <summary>
 169        /// This header returns the value that was specified for the Content-Language request header.
 170        /// </summary>
 368171        public string ContentLanguage { get; internal set; }
 172
 173        /// <summary>
 174        /// The current sequence number for a page blob. This header is not returned for block blobs or append blobs
 175        /// </summary>
 0176        public long BlobSequenceNumber { get; internal set; }
 177
 178        /// <summary>
 179        /// Conclusion time of the last attempted Copy Blob operation where this blob was the destination blob. This val
 180        /// </summary>
 368181        public DateTimeOffset CopyCompletedOn { get; internal set; }
 182
 183        /// <summary>
 184        /// Only appears when x-ms-copy-status is failed or pending. Describes the cause of the last fatal or non-fatal 
 185        /// </summary>
 368186        public string CopyStatusDescription { get; internal set; }
 187
 188        /// <summary>
 189        /// String identifier for this copy operation. Use with Get Blob Properties to check the status of this copy ope
 190        /// </summary>
 368191        public string CopyId { get; internal set; }
 192
 193        /// <summary>
 194        /// Contains the number of bytes copied and the total bytes in the source in the last attempted Copy Blob operat
 195        /// </summary>
 368196        public string CopyProgress { get; internal set; }
 197
 198        /// <summary>
 199        /// URL up to 2 KB in length that specifies the source blob or file used in the last attempted Copy Blob operati
 200        /// </summary>
 0201        public Uri CopySource { get; internal set; }
 202
 203        /// <summary>
 204        /// State of the copy operation identified by x-ms-copy-id.
 205        /// </summary>
 368206        public CopyStatus CopyStatus { get; internal set; }
 207
 208        /// <summary>
 209        /// When a blob is leased, specifies whether the lease is of infinite or fixed duration.
 210        /// </summary>
 368211        public LeaseDurationType LeaseDuration { get; internal set; }
 212
 213        /// <summary>
 214        /// Lease state of the blob.
 215        /// </summary>
 368216        public LeaseState LeaseState { get; internal set; }
 217
 218        /// <summary>
 219        /// The current lease status of the blob.
 220        /// </summary>
 368221        public LeaseStatus LeaseStatus { get; internal set; }
 222
 223        /// <summary>
 224        /// Indicates that the service supports requests for partial blob content.
 225        /// </summary>
 368226        public string AcceptRanges { get; internal set; }
 227
 228        /// <summary>
 229        /// The number of committed blocks present in the blob. This header is returned only for append blobs.
 230        /// </summary>
 0231        public int BlobCommittedBlockCount { get; internal set; }
 232
 233        /// <summary>
 234        /// The value of this header is set to true if the blob data and application metadata are completely encrypted u
 235        /// </summary>
 368236        public bool IsServerEncrypted { get; internal set; }
 237
 238        /// <summary>
 239        /// The SHA-256 hash of the encryption key used to encrypt the blob. This header is only returned when the blob 
 240        /// </summary>
 1206241        public string EncryptionKeySha256 { get; internal set; }
 242
 243        /// <summary>
 244        /// The encryption scope used to encrypt the blob.
 245        /// </summary>
 838246        public string EncryptionScope { get; internal set; }
 247
 248        /// <summary>
 249        /// If the blob has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header
 250        /// </summary>
 251#pragma warning disable CA1819 // Properties should not return arrays
 368252        public byte[] BlobContentHash { get; internal set; }
 253#pragma warning restore CA1819 // Properties should not return arrays
 254
 255        /// <summary>
 256        /// The number of tags associated with the blob.
 257        /// </summary>
 838258        public long TagCount { get; internal set; }
 259
 260        /// <summary>
 261        /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicat
 262        /// </summary>
 838263        public string VersionId { get; internal set; }
 264
 265        /// <summary>
 266        /// If this blob is sealed.
 267        /// </summary>
 838268        public bool IsSealed { get; internal set; }
 269
 270        /// <summary>
 271        /// x-ms-or
 272        /// </summary>
 842273        public IList<ObjectReplicationPolicy> ObjectReplicationSourceProperties { get; internal set; }
 274
 275        /// <summary>
 276        /// Object Replication Policy Id. This value is only set when the policy id
 277        /// </summary>
 842278        public string ObjectReplicationDestinationPolicyId { get; internal set; }
 279    }
 280
 281    /// <summary>
 282    /// BlobsModelFactory provides utilities for mocking.
 283    /// </summary>
 284    public static partial class BlobsModelFactory
 285    {
 286        /// <summary>
 287        /// Creates a new BlobDownloadInfo instance for mocking.
 288        /// </summary>
 289        public static BlobDownloadInfo BlobDownloadInfo(
 290            DateTimeOffset lastModified = default,
 291            long blobSequenceNumber = default,
 292            BlobType blobType = default,
 293            byte[] contentCrc64 = default,
 294            string contentLanguage = default,
 295            string copyStatusDescription = default,
 296            string copyId = default,
 297            string copyProgress = default,
 298            Uri copySource = default,
 299            CopyStatus copyStatus = default,
 300            string contentDisposition = default,
 301            LeaseDurationType leaseDuration = default,
 302            string cacheControl = default,
 303            LeaseState leaseState = default,
 304            string contentEncoding = default,
 305            LeaseStatus leaseStatus = default,
 306            byte[] contentHash = default,
 307            string acceptRanges = default,
 308            ETag eTag = default,
 309            int blobCommittedBlockCount = default,
 310            string contentRange = default,
 311            bool isServerEncrypted = default,
 312            string contentType = default,
 313            string encryptionKeySha256 = default,
 314            string encryptionScope = default,
 315            long contentLength = default,
 316            byte[] blobContentHash = default,
 317            string versionId = default,
 318            IDictionary<string, string> metadata = default,
 319            Stream content = default,
 320            DateTimeOffset copyCompletionTime = default,
 321            long tagCount = default)
 322        {
 323            return new BlobDownloadInfo(
 324                new FlattenedDownloadProperties()
 325                {
 326                    LastModified = lastModified,
 327                    BlobSequenceNumber = blobSequenceNumber,
 328                    BlobType = blobType,
 329                    ContentCrc64 = contentCrc64,
 330                    ContentLanguage = contentLanguage,
 331                    CopyStatusDescription = copyStatusDescription,
 332                    CopyId = copyId,
 333                    CopyProgress = copyProgress,
 334                    CopySource = copySource,
 335                    CopyStatus = copyStatus,
 336                    ContentDisposition = contentDisposition,
 337                    LeaseDuration = leaseDuration,
 338                    CacheControl = cacheControl,
 339                    LeaseState = leaseState,
 340                    ContentEncoding = contentEncoding,
 341                    LeaseStatus = leaseStatus,
 342                    ContentHash = contentHash,
 343                    AcceptRanges = acceptRanges,
 344                    ETag = eTag,
 345                    BlobCommittedBlockCount = blobCommittedBlockCount,
 346                    ContentRange = contentRange,
 347                    IsServerEncrypted = isServerEncrypted,
 348                    ContentType = contentType,
 349                    EncryptionKeySha256 = encryptionKeySha256,
 350                    EncryptionScope = encryptionScope,
 351                    ContentLength = contentLength,
 352                    BlobContentHash = blobContentHash,
 353                    Metadata = metadata,
 354                    Content = content,
 355                    CopyCompletionTime = copyCompletionTime,
 356                    VersionId = versionId,
 357                    TagCount = tagCount
 358                }
 359            );
 360        }
 361
 362        /// <summary>
 363        /// Creates a new BlobDownloadInfo instance for mocking.
 364        /// </summary>
 365        [EditorBrowsable(EditorBrowsableState.Never)]
 366        public static BlobDownloadInfo BlobDownloadInfo(
 367            DateTimeOffset lastModified,
 368            long blobSequenceNumber,
 369            BlobType blobType,
 370            byte[] contentCrc64,
 371            string contentLanguage,
 372            string copyStatusDescription,
 373            string copyId,
 374            string copyProgress,
 375            Uri copySource,
 376            CopyStatus copyStatus,
 377            string contentDisposition,
 378            LeaseDurationType leaseDuration,
 379            string cacheControl,
 380            LeaseState leaseState,
 381            string contentEncoding,
 382            LeaseStatus leaseStatus,
 383            byte[] contentHash,
 384            string acceptRanges,
 385            ETag eTag,
 386            int blobCommittedBlockCount,
 387            string contentRange,
 388            bool isServerEncrypted,
 389            string contentType,
 390            string encryptionKeySha256,
 391            string encryptionScope,
 392            long contentLength,
 393            byte[] blobContentHash,
 394            IDictionary<string, string> metadata,
 395            Stream content,
 396            DateTimeOffset copyCompletionTime)
 397        {
 398            return new BlobDownloadInfo(
 399                new FlattenedDownloadProperties()
 400                {
 401                    LastModified = lastModified,
 402                    BlobSequenceNumber = blobSequenceNumber,
 403                    BlobType = blobType,
 404                    ContentCrc64 = contentCrc64,
 405                    ContentLanguage = contentLanguage,
 406                    CopyStatusDescription = copyStatusDescription,
 407                    CopyId = copyId,
 408                    CopyProgress = copyProgress,
 409                    CopySource = copySource,
 410                    CopyStatus = copyStatus,
 411                    ContentDisposition = contentDisposition,
 412                    LeaseDuration = leaseDuration,
 413                    CacheControl = cacheControl,
 414                    LeaseState = leaseState,
 415                    ContentEncoding = contentEncoding,
 416                    LeaseStatus = leaseStatus,
 417                    ContentHash = contentHash,
 418                    AcceptRanges = acceptRanges,
 419                    ETag = eTag,
 420                    BlobCommittedBlockCount = blobCommittedBlockCount,
 421                    ContentRange = contentRange,
 422                    IsServerEncrypted = isServerEncrypted,
 423                    ContentType = contentType,
 424                    EncryptionKeySha256 = encryptionKeySha256,
 425                    EncryptionScope = encryptionScope,
 426                    ContentLength = contentLength,
 427                    BlobContentHash = blobContentHash,
 428                    Metadata = metadata,
 429                    Content = content,
 430                    CopyCompletionTime = copyCompletionTime
 431                }
 432            );
 433        }
 434
 435        /// <summary>
 436        /// Creates a new BlobDownloadInfo instance for mocking.
 437        /// </summary>
 438        [EditorBrowsable(EditorBrowsableState.Never)]
 439        public static BlobDownloadInfo BlobDownloadInfo(
 440            DateTimeOffset lastModified,
 441            long blobSequenceNumber,
 442            BlobType blobType,
 443            byte[] contentCrc64,
 444            string contentLanguage,
 445            string copyStatusDescription,
 446            string copyId,
 447            string copyProgress,
 448            Uri copySource,
 449            CopyStatus copyStatus,
 450            string contentDisposition,
 451            LeaseDurationType leaseDuration,
 452            string cacheControl,
 453            LeaseState leaseState,
 454            string contentEncoding,
 455            LeaseStatus leaseStatus,
 456            byte[] contentHash,
 457            string acceptRanges,
 458            ETag eTag,
 459            int blobCommittedBlockCount,
 460            string contentRange,
 461            bool isServerEncrypted,
 462            string contentType,
 463            string encryptionKeySha256,
 464            long contentLength,
 465            byte[] blobContentHash,
 466            IDictionary<string, string> metadata,
 467            Stream content,
 468            DateTimeOffset copyCompletionTime)
 469        {
 470            return new BlobDownloadInfo(
 471                new FlattenedDownloadProperties()
 472                {
 473                    LastModified = lastModified,
 474                    BlobSequenceNumber = blobSequenceNumber,
 475                    BlobType = blobType,
 476                    ContentCrc64 = contentCrc64,
 477                    ContentLanguage = contentLanguage,
 478                    CopyStatusDescription = copyStatusDescription,
 479                    CopyId = copyId,
 480                    CopyProgress = copyProgress,
 481                    CopySource = copySource,
 482                    CopyStatus = copyStatus,
 483                    ContentDisposition = contentDisposition,
 484                    LeaseDuration = leaseDuration,
 485                    CacheControl = cacheControl,
 486                    LeaseState = leaseState,
 487                    ContentEncoding = contentEncoding,
 488                    LeaseStatus = leaseStatus,
 489                    ContentHash = contentHash,
 490                    AcceptRanges = acceptRanges,
 491                    ETag = eTag,
 492                    BlobCommittedBlockCount = blobCommittedBlockCount,
 493                    ContentRange = contentRange,
 494                    IsServerEncrypted = isServerEncrypted,
 495                    ContentType = contentType,
 496                    EncryptionKeySha256 = encryptionKeySha256,
 497                    ContentLength = contentLength,
 498                    BlobContentHash = blobContentHash,
 499                    Metadata = metadata,
 500                    Content = content,
 501                    CopyCompletionTime = copyCompletionTime
 502                }
 503            );
 504        }
 505    }
 506}