/// <summary> /// Downloads a file from the Azure Shares files storage by calling <see cref="ShareFileClient.DownloadAsync(HttpRange, bool, CancellationToken)"/>. /// </summary> /// <param name="cancellationToken">The token used to signal cancellation request.</param> public override async Task RunAsync(CancellationToken cancellationToken) { Models.ShareFileDownloadInfo fileDownloadInfo = await _fileClient.DownloadAsync(cancellationToken : cancellationToken); // Copy the stream so it is actually downloaded. We use a local memory stream as destination to avoid the cost of copying to a file on disk. await fileDownloadInfo.Content.CopyToAsync(Stream.Null, (int)_stream.Length, cancellationToken : cancellationToken); #if DEBUG Console.WriteLine($"Downloaded file from {_fileClient.Path}. Content length: {fileDownloadInfo.ContentLength}"); #endif }
/// <summary> /// Downloads a file from the Azure Shares files storage by calling <see cref="ShareFileClient.Download(HttpRange, bool, CancellationToken)"/>. /// </summary> /// <param name="cancellationToken">The token used to signal cancellation request.</param> public override void Run(CancellationToken cancellationToken) { Models.ShareFileDownloadInfo fileDownloadInfo = _fileClient.Download(cancellationToken: cancellationToken); // Copy the stream so it is actually downloaded. We use a memory stream as destination to avoid the cost of copying to a file on disk. fileDownloadInfo.Content.CopyTo(Stream.Null); #if DEBUG Console.WriteLine($"Downloaded file from {_fileClient.Path}. Content length: {fileDownloadInfo.ContentLength}"); #endif }