public async Task <Stream> OpenReadAsync(string fullPath, CancellationToken cancellationToken = default) { GenericValidation.CheckBlobFullPath(fullPath); (CloudBlobContainer container, string path) = await GetPartsAsync(fullPath, false); if (container == null) { return(null); } CloudBlockBlob blob = container.GetBlockBlobReference(StoragePath.Normalize(path, false)); try { return(await blob.OpenReadAsync()); } catch (AzureStorageException ex) { if (AzureStorageValidation.IsDoesntExist(ex)) { return(null); } if (!AzureStorageValidation.TryHandleStorageException(ex)) { throw; } } throw new InvalidOperationException("must not be here"); }
public async Task <string> GetSasUriAsync( string fullPath, SharedAccessBlobPolicy sasConstraints, SharedAccessBlobHeaders headers, bool createContainer, CancellationToken cancellationToken) { GenericValidation.CheckBlobFullPath(fullPath); (CloudBlobContainer container, string path) = await GetPartsAsync(fullPath, createContainer); if (container == null) { return(null); } CloudBlockBlob blob = container.GetBlockBlobReference(StoragePath.Normalize(path, false)); try { return($@"{blob.Uri}{blob.GetSharedAccessSignature(sasConstraints, headers)}"); } catch (AzureStorageException ex) { if (AzureStorageValidation.IsDoesntExist(ex)) { return(null); } if (!AzureStorageValidation.TryHandleStorageException(ex)) { throw; } } throw new InvalidOperationException("must not be here"); }