Example #1
0
        private UploadProgress GetProgressObject(FileIdentifier id)
        {
            var progressObject = this._uploadProgressManager.GetProgress(id);

            if (progressObject == null)
            {
                progressObject = new UploadProgress();

                Debug.Fail("Unable to retrieve progress object - which should have been set by the handler.");
            }

            return(progressObject);
        }
Example #2
0
        private async Task StoreDataAsync(FileIdentifier id, Stream dataStream, CancellationToken cancellationToken)
        {
            UploadProgress progress = this.GetProgressObject(id);

            // Copy with progress
            using (Stream outputStream = this._fileWriter.OpenWriteStream(this._fileStore.GetDataFile(id))) {
                using (Stream inputStream = dataStream) {
                    int    read;
                    byte[] buffer = new byte[4096];
                    while ((read = await inputStream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0)
                    {
                        progress.Current += read;

                        await outputStream.WriteAsync(buffer, 0, read, cancellationToken).ConfigureAwait(false);
                    }
                }
            }
        }
Example #3
0
 public void SetProgress(FileIdentifier id, UploadProgress uploadProgress)
 {
     this._uploadsByFileIdentifier[id] = uploadProgress;
 }