示例#1
0
        public Task <StorageBlobInfo> BlobInfoAsync(string containerName, string fileName)
        {
            if (string.IsNullOrEmpty(containerName))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(containerName));
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(fileName));
            }

            var filePath = FilePath(containerName, fileName);
            var fileInfo = new FileInfo(filePath);

            var ret = new StorageBlobInfo
            {
                Container = new StorageBlobContainerInfo {
                    Name = containerName, Uri = new Uri($"file://{containerName}")
                },
                ContentType = MimeUtility.GetMimeMapping(fileName),
                Filename    = fileName,
                Size        = fileInfo.Length,
                Uri         = new Uri($"file://{containerName}/{fileName}"),
                AbsoluteUri = $"file://{containerName}/{fileName}"
            };

            return(Task.FromResult(ret));
        }
        private static StorageBlobInfo BlobInfo(CloudBlobContainer container, CloudBlob blob)
        {
            var ret = new StorageBlobInfo
            {
                Container   = ContainerInfo(container),
                Filename    = blob.Name,
                ContentType = blob.Properties.ContentType,
                Size        = blob.Properties.Length,
                Uri         = blob.Uri,
                AbsoluteUri = blob.Uri.AbsoluteUri
            };

            return(ret);
        }