/// <summary>
/// Gets the data for a given blob from R-Host. Saves the data to <paramref name="filePath"/>. This
/// method adds the blob for clean up by default.
/// </summary>
/// <param name="blob">Blob from which the data is to be retrieved.</param>
/// <param name="filePath">Path to the file where the retrieved data will be written.</param>
/// <param name="doCleanUp">true to add blob upon transfer for cleanup on dispose, false to ignore it after transfer.</param>
public async Task FetchFileAsync(IRBlobInfo blob, string filePath, bool doCleanUp, IProgress <long> progress, CancellationToken cancellationToken)
{
using (RBlobStream blobStream = await RBlobStream.OpenAsync(blob, _blobService))
using (Stream fileStream = _fs.CreateFile(filePath)) {
await blobStream.CopyToAsync(fileStream, progress, cancellationToken);
}
if (doCleanUp)
{
_cleanup.Add(blob);
}
}