/// <inheritdoc /> public async Task <CloudBlockBlob> GetBlobAsync(string blobName, string containerName) { var cloudBlobContainer = await _connectionFactory.GetBlobContainer(containerName); CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(blobName); return(blockBlob); }
/// <inheritdoc /> public async Task <CloudBlockBlob> GetBlobAsync(string blobNameWithExtension) { var cloudBlobContainer = await _connectionFactory.GetBlobContainer(_containerNameKey); CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(blobNameWithExtension); return(blockBlob); }
public async Task DeleteAsync(string fileUri, string name) { var blobContainer = await _azureBlobConnectionFactory.GetBlobContainer(name); var uri = new Uri(fileUri); string filename = Path.GetFileName(uri.LocalPath); var blob = blobContainer.GetBlockBlobReference(filename); await blob.DeleteIfExistsAsync(); }
public async Task DeleteAllAsync() { var blobContainer = await _azureBlobConnectionFactory.GetBlobContainer(); BlobContinuationToken blobContinuationToken = null; do { var response = await blobContainer.ListBlobsSegmentedAsync(blobContinuationToken); //not overload foreach (IListBlobItem blob in response.Results) { if (blob.GetType() == typeof(CloudBlockBlob)) await ((CloudBlockBlob)blob).DeleteIfExistsAsync(); } blobContinuationToken = response.ContinuationToken; } while (blobContinuationToken != null); }
public async Task <MemoryStream> DownloadFileAsync(string fileUri, string containerName) { var blobContainer = await _connectionFactory.GetBlobContainer(containerName).ConfigureAwait(false); var uri = new Uri(fileUri); var directory = blobContainer.GetDirectoryReference(uri.Segments[URL_PARTS_COUNT].TrimEnd('/')); var filename = Path.GetFileName(uri.LocalPath); var blob = directory.GetBlobReference(filename); var memStream = new MemoryStream(); await blob.DownloadToStreamAsync(memStream); memStream.Seek(0, SeekOrigin.Begin); return(memStream); }
public async Task <IEnumerable <Uri> > ListAsync() { var blobContainer = await _azureBlobConnectionFactory.GetBlobContainer(); var allBlobs = new List <Uri>(); BlobContinuationToken blobContinuationToken = null; do { var response = await blobContainer.ListBlobsSegmentedAsync(blobContinuationToken); foreach (var blob in response.Results) { allBlobs.Add(blob.Uri); } blobContinuationToken = response.ContinuationToken; } while (blobContinuationToken != null); return(allBlobs); }
public async Task <IEnumerable <Uri> > ListAsync() { var blobContainer = await azureBlobConnectionFactory.GetBlobContainer(); var allBlobs = new List <Uri>(); BlobContinuationToken blobContinuationToken = null; do { BlobResultSegment response = await blobContainer.ListBlobsSegmentedAsync(blobContinuationToken); foreach (IListBlobItem blob in response.Results) { if (blob.GetType() == typeof(CloudBlockBlob)) { allBlobs.Add(blob.Uri); } } blobContinuationToken = response.ContinuationToken; } while (blobContinuationToken != null); return(allBlobs); }
private async Task <string> UploadAsync(IFormFileCollection files) { string blobUrl = null; var blobContainer = await _azureBlobConnectionFactory.GetBlobContainer(); foreach (var t in files) { var blob = blobContainer.GetBlockBlobReference(GetRandomBlobName(t.FileName)); blobUrl = blob.Uri.AbsoluteUri; await using var stream = t.OpenReadStream(); await blob.UploadFromStreamAsync(stream); } return(blobUrl); }
public async Task <string> GetBlobUriAsync() { var blobContainer = await _azureBlobConnectionFactory.GetBlobContainer(); return(blobContainer.Uri.AbsoluteUri); }