Example #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));
        }
Example #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)));
        }