Пример #1
0
 /// <summary>
 ///		Muestra los metadatos de un blob
 /// </summary>
 private static void ShowMetadata(MetadataBlobModel metadata)
 {
     Console.WriteLine($"Nombre: {metadata.Name}");
     Console.WriteLine($"Uri: {metadata.Uri}");
     Console.WriteLine($"Length: {metadata.Length}");
     Console.WriteLine($"Etag: {metadata.ETag}");
     Console.WriteLine($"LastModified: {metadata.LastModified}");
     ShowMetadataProperties(metadata.Properties);
 }
Пример #2
0
        /// <summary>
        ///		Obtiene los metadatos de un blob
        /// </summary>
        public async Task <MetadataBlobModel> GetMetadataAsync(string container, string blobFileName)
        {
            MetadataBlobModel metadata = new MetadataBlobModel();
            CloudBlob         blob     = await GetBlobAsync(container, blobFileName);

            // Captura los atributos
            await blob.FetchAttributesAsync();

            // Asigna los metadatos
            metadata.Name         = blob.Name;
            metadata.Uri          = blob.Uri;
            metadata.ETag         = blob.Properties.ETag;
            metadata.LastModified = blob.Properties.LastModified ?? DateTime.UtcNow;
            metadata.Length       = blob.Properties.Length;
            metadata.StreamMinimumReadSizeInBytes = blob.StreamMinimumReadSizeInBytes;
            metadata.ContainerName = blob.Container.Name;
            metadata.Type          = Convert(blob.Properties.BlobType);
            metadata.IsSnaphot     = blob.IsSnapshot;
            if (blob.IsSnapshot)
            {
                metadata.SnapshotTime         = blob.SnapshotTime;
                metadata.SnapshotQualifiedUri = blob.SnapshotQualifiedUri;
            }
            metadata.IsDeleted = blob.IsDeleted;
            // Añade las propiedades del blob
            foreach (KeyValuePair <string, string> item in blob.Metadata)
            {
                metadata.Properties.Add(item.Key, item.Value);
            }
            // Devuelve el objeto
            return(metadata);

            //Console.WriteLine("\t LeaseState: {0}", blob.Properties.LeaseState);
            //// If the blob has been leased, write out lease properties.
            //if (blob.Properties.LeaseState != LeaseState.Available)
            //{
            //    Console.WriteLine("\t LeaseDuration: {0}", blob.Properties.LeaseDuration);
            //    Console.WriteLine("\t LeaseStatus: {0}", blob.Properties.LeaseStatus);
            //}
            //Console.WriteLine("\t CacheControl: {0}", blob.Properties.CacheControl);
            //Console.WriteLine("\t ContentDisposition: {0}", blob.Properties.ContentDisposition);
            //Console.WriteLine("\t ContentEncoding: {0}", blob.Properties.ContentEncoding);
            //Console.WriteLine("\t ContentLanguage: {0}", blob.Properties.ContentLanguage);
            //Console.WriteLine("\t ContentMD5: {0}", blob.Properties.ContentMD5);
            //Console.WriteLine("\t ContentType: {0}", blob.Properties.ContentType);
            // Write out properties specific to blob type.
            //switch (blob.BlobType)
            //{
            //    case BlobType.AppendBlob:
            //        CloudAppendBlob appendBlob = blob as CloudAppendBlob;
            //        Console.WriteLine("\t AppendBlobCommittedBlockCount: {0}", appendBlob.Properties.AppendBlobCommittedBlockCount);
            //        Console.WriteLine("\t StreamWriteSizeInBytes: {0}", appendBlob.StreamWriteSizeInBytes);
            //        break;
            //    case BlobType.BlockBlob:
            //        CloudBlockBlob blockBlob = blob as CloudBlockBlob;
            //        Console.WriteLine("\t StreamWriteSizeInBytes: {0}", blockBlob.StreamWriteSizeInBytes);
            //        break;
            //    case BlobType.PageBlob:
            //        CloudPageBlob pageBlob = blob as CloudPageBlob;
            //        Console.WriteLine("\t PageBlobSequenceNumber: {0}", pageBlob.Properties.PageBlobSequenceNumber);
            //        Console.WriteLine("\t StreamWriteSizeInBytes: {0}", pageBlob.StreamWriteSizeInBytes);
            //        break;
            //    default:
            //        break;
        }