public async Task <IFileDescriptor> GetBlobMetaDataAsync(string fileId)
        {
            //string fileId = fileRef.Value;
            var containerClient = await GetBlobContainerAsync();

            BlobClient blobClient = containerClient.GetBlobClient(fileId);

            if (await blobClient.ExistsAsync())
            {
                BlobProperties properties = await blobClient.GetPropertiesAsync();

                var fileName = properties.Metadata[FileNameMetaDataAttribut];
                return(new FileDescriptor()
                {
                    Id = fileId,
                    FileName = fileName,
                    ContentType = properties.ContentType,
                    Size = properties.ContentLength
                });
            }
            else
            {
                throw new Exception("Blob doesn't exist");
            }
        }
Example #2
0
        private static async Task GetBlobPropertiesAsync(BlobClient blobClient)
        {
            Console.WriteLine($"4. Get blob properties");

            var properties = await blobClient.GetPropertiesAsync();

            Console.WriteLine($"   - Content type: {properties.Value.ContentType}");
            Console.WriteLine($"   - Blob type: {properties.Value.BlobType}");
            Console.WriteLine($"   - Created on: {properties.Value.CreatedOn}");
            Console.WriteLine($"   - Last modified: {properties.Value.LastModified}");
        }
Example #3
0
        private static async Task GetBlobMetadataAsync(BlobClient blobClient)
        {
            Console.WriteLine($"6. Get blob metadata");

            var blobProperties = await blobClient.GetPropertiesAsync();

            foreach (var metadata in blobProperties.Value.Metadata)
            {
                Console.WriteLine($"    - {metadata.Key} : {metadata.Value}");
            }
        }
Example #4
0
        private static async Task SetBlobPropertiesAsync(BlobClient blobClient)
        {
            Console.WriteLine($"3. Set blob properties");

            var blobProperties = await blobClient.GetPropertiesAsync();

            BlobHttpHeaders headers = new()
            {
                ContentType     = "text/html",
                ContentLanguage = "en-us",

                CacheControl       = blobProperties.Value.CacheControl,
                ContentDisposition = blobProperties.Value.ContentDisposition,
                ContentEncoding    = blobProperties.Value.ContentEncoding,
                ContentHash        = blobProperties.Value.ContentHash
            };

            await blobClient.SetHttpHeadersAsync(headers);
        }