Esempio n. 1
0
        public async Task DeleteFileAsync(string path)
        {
            var container = AzureCloudHelpers.GetBlobContainer();
            var blob      = container.GetBlockBlobReference(path);

            await blob.DeleteAsync();
        }
Esempio n. 2
0
 public async Task UploadFileAsync(IFormFile file, string generatedFileName)
 {
     try
     {
         var blobContainer = AzureCloudHelpers.GetBlobContainer();
         var blob          = blobContainer.GetBlockBlobReference(generatedFileName);
         using (var fs = file.OpenReadStream())
             await blob.UploadFromStreamAsync(fs);
     }
     catch (Exception)
     {
         throw new AzureException(
                   "Failed to connect to Azure Blob from docker container! Please reboot docker and try again!");
     }
 }
Esempio n. 3
0
        public async Task <Stream> DownloadFileAsync(string path)
        {
            try
            {
                var containter = AzureCloudHelpers.GetBlobContainer();
                var blob       = containter.GetBlockBlobReference(path);

                var ms = new MemoryStream();
                await blob.DownloadToStreamAsync(ms);

                return(ms);
            }
            catch (Exception)
            {
                throw new AzureException(
                          "Failed to connect to Azure Blob from docker container! Please reboot docker and try again!");
            }
        }