Ejemplo n.º 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));
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 3
0
 private async Task <long> GetBlobSize(CloudBlockBlob blob)
 {
     return(await StorageUtils.GetBlobSize(blob));
 }
Ejemplo n.º 4
0
 public CloudStorageService(IConfiguration configuration)
 {
     _cloudStorageAccount = StorageUtils.GetCloudStorageAccount(configuration["Azure:Storage:ConnectionString"]);
 }
Ejemplo n.º 5
0
 private async Task <bool> UploadBlobToContainer(CloudBlockBlob blob, byte[] fileContent)
 {
     return(await StorageUtils.UploadBlob(blob, fileContent));
 }