public override async Task<AsyncDisposableValue<Stream>> OpenWriteAsync(CancellationToken cancellationToken = new CancellationToken()) { var stream = new ArrayPoolMemoryStream(InitialCapacity, ArrayPool ?? ArrayPool<byte>.Shared); return new AsyncDisposableValue<Stream>(stream, async () => { stream.Seek(0, SeekOrigin.Begin); await BlockBlob.UploadFromStreamAsync(stream, cancellationToken); }); }
public override async Task<AsyncDisposableValue<Stream>> OpenReadAsync(CancellationToken cancellationToken = new CancellationToken()) { if (!await BlockBlob.ExistsAsync(cancellationToken)) throw new ResourceNotFoundException("Metadata not found for this store"); cancellationToken.ThrowIfCancellationRequested(); var stream = new ArrayPoolMemoryStream(InitialCapacity, ArrayPool ?? ArrayPool<byte>.Shared); await BlockBlob.DownloadToStreamAsync(stream, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); stream.Seek(0, SeekOrigin.Begin); return new AsyncDisposableValue<Stream>(stream, async () => stream.Dispose()); }