Пример #1
0
        public Uri GetDownloadUri(StorageItem item)
        {
            if (item.GetType() == typeof(Folder))
            {
                throw new NotImplementedException("Don't support download links for folders.");
            }

            var sasBuilder = new BlobSasBuilder
            {
                BlobContainerName  = m_blobContainerClient.Name,
                BlobName           = $"{item.DriveId}/{item.Id}",
                Resource           = "b",
                ExpiresOn          = DateTimeOffset.UtcNow.AddHours(1),
                ContentDisposition = $"attachment;filename={item.Name}"
            };

            sasBuilder.SetPermissions(BlobSasPermissions.Read);

            return(m_blobContainerClient.GetBlobClient($"{item.DriveId}/{item.Id}")
                   .GenerateSasUri(sasBuilder));
        }