Пример #1
0
        public async Task <string> GetReadOnlyBlobSasToken(string containerName, string folderName, string fileName)
        {
            // container
            var container = await StorageUtils.GetBlobContainer(_cloudStorageAccount, containerName);

            var blobName = StorageUtils.GetFileName(container, folderName, fileName);

            return(StorageUtils.GetReadOnlyBlobSasUri(container, blobName));
        }
Пример #2
0
        private async Task <CloudBlockBlob> GetWritableBlob(string containerName, string fileName, string folderName = null)
        {
            // get/create container
            var container = await StorageUtils.GetBlobContainer(_cloudStorageAccount, containerName);

            // generate the nested file name
            string nestedFileName = folderName != null ? $"{folderName}{container.ServiceClient.DefaultDelimiter}{fileName}" : $"{fileName}";

            // get sas token
            var sasUri = StorageUtils.GetBlobSasUri(container, nestedFileName, null);

            // Return a reference to the blob using the SAS URI. This allows us to upload file contents without having to submit SAS as a query.
            return(new CloudBlockBlob(new Uri(sasUri)));
        }
Пример #3
0
 private async Task <long> GetBlobSize(CloudBlockBlob blob)
 {
     return(await StorageUtils.GetBlobSize(blob));
 }
Пример #4
0
 public CloudStorageService(IConfiguration configuration)
 {
     _cloudStorageAccount = StorageUtils.GetCloudStorageAccount(configuration["Azure:Storage:ConnectionString"]);
 }
Пример #5
0
 private async Task <bool> UploadBlobToContainer(CloudBlockBlob blob, byte[] fileContent)
 {
     return(await StorageUtils.UploadBlob(blob, fileContent));
 }