Ejemplo n.º 1
0
        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 = await BlockBlob.OpenReadAsync(cancellationToken);

            return(new AsyncDisposableValue <Stream>(stream, async() => stream.Dispose()));
        }
        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 MemoryStream(InitialCapacity);

            await BlockBlob.DownloadToStreamAsync(stream, cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            stream.Seek(0, SeekOrigin.Begin);

            return(new AsyncDisposableValue <Stream>(stream, async() => stream.Dispose()));
        }