diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs index dfbd9f93a..603463823 100644 --- a/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs +++ b/Software/Visual_Studio/Tango.Transport/Web/StorageBlobDownloader.cs @@ -9,33 +9,30 @@ using Tango.Core.IO; namespace Tango.Transport.Web { - public class StorageBlobDownloader : IWebFileDownloader + public class StorageBlobDownloader : IDisposable { private bool _disposed; private FileStreamWrapper _stream; private long _fileSize; - private String _fileName; public CloudBlockBlob Blob { get; private set; } - public String Address { get; private set; } - - public event EventHandler<WebFileDownloaderProgressEventArgs> Progress; + public event EventHandler<StorageBlobProgressEventArgs> Progress; public StorageBlobDownloader(CloudBlockBlob blob, String fileName) { Blob = blob; - _fileName = fileName; + _stream = new FileStreamWrapper(fileName, FileMode.Create, OnProgress); } public StorageBlobDownloader(String blobAddress, String fileName) : this(new CloudBlockBlob(new Uri(blobAddress)), fileName) { - Address = blobAddress; + } private void OnProgress(long current) { - Progress?.Invoke(this, new WebFileDownloaderProgressEventArgs() + Progress?.Invoke(this, new StorageBlobProgressEventArgs() { Current = current, Total = _fileSize, @@ -52,8 +49,6 @@ namespace Tango.Transport.Web await Blob.FetchAttributesAsync(); _fileSize = Blob.Properties.Length; - _stream = new FileStreamWrapper(_fileName, FileMode.Create, OnProgress); - await Blob.DownloadToStreamAsync(_stream); Dispose(); } @@ -63,18 +58,8 @@ namespace Tango.Transport.Web if (!_disposed) { _disposed = true; - - if (_stream != null) - { - _stream.Dispose(); - } + _stream.Dispose(); } } - - public async Task<long> GetFileSize() - { - await Blob.FetchAttributesAsync(); - return Blob.Properties.Length; - } } } |
