示例#1
0
        public async Task DeleteAsync(string fileName, EContainerName eContainerName)
        {
            var containerClient = _blobServiceClient.GetBlobContainerClient(eContainerName.ToString());

            var blobClient = containerClient.GetBlobClient(fileName);

            await blobClient.DeleteAsync();
        }
示例#2
0
        public async Task <Stream> DownloadAsync(string blobClientName, EContainerName eContainerName)
        {
            var containerClient = _blobServiceClient.GetBlobContainerClient(eContainerName.ToString());
            var blobClient      = containerClient.GetBlobClient(blobClientName);
            var downloadedFile  = await blobClient.DownloadAsync();

            return(downloadedFile.Value.Content);
        }
示例#3
0
        public async Task <Stream> DownloadAsync(string fileName, EContainerName eContanierName)
        {
            var contanierClient = _blobServiceClient.GetBlobContainerClient(eContanierName.ToString());
            var blobClient      = contanierClient.GetBlobClient(fileName);
            var info            = await blobClient.DownloadAsync();

            return(info.Value.Content);
        }
示例#4
0
        public List <string> GetNames(EContainerName eContainerName)
        {
            var blobNames       = new List <string>();
            var containerClient = _blobServiceClient.GetBlobContainerClient(eContainerName.ToString());
            var blobs           = containerClient.GetBlobs();

            blobs.ToList().ForEach(b => blobNames.Add(b.Name));
            return(blobNames);
        }
示例#5
0
        public async Task UploadAsync(Stream fileStream, string blobClientName, EContainerName eContainerName)
        {
            var containerClient = _blobServiceClient.GetBlobContainerClient(eContainerName.ToString());
            await containerClient.CreateIfNotExistsAsync();

            await containerClient.SetAccessPolicyAsync(Azure.Storage.Blobs.Models.PublicAccessType.BlobContainer);

            var blobClient = containerClient.GetBlobClient(blobClientName);
            await blobClient.UploadAsync(fileStream);
        }