Пример #1
0
        public Task <INode> UploadAsync(Stream stream, string name, INode parent, IProgress <double> progress)
        {
            return(Task.Run(() =>
            {
                if (stream == null)
                {
                    throw new ArgumentNullException("stream");
                }

                using (Stream progressionStream = new ProgressionStream(stream, progress, this.ReportProgressChunkSize))
                {
                    return this.Upload(progressionStream, name, parent);
                }
            }));
        }
Пример #2
0
        public Task <INode> UploadAsync(Stream stream, string name, INode parent, IProgress <double> progress = null, DateTime?modificationDate = null, CancellationToken?cancellationToken = null)
        {
            return(Task.Run(() =>
            {
                if (stream == null)
                {
                    throw new ArgumentNullException("stream");
                }

                using (Stream progressionStream = new ProgressionStream(stream, progress, _options.ReportProgressChunkSize))
                {
                    return Upload(progressionStream, name, parent, modificationDate, cancellationToken);
                }
            }, cancellationToken.GetValueOrDefault()));
        }
Пример #3
0
        public Task DownloadFileAsync(Uri uri, string outputFile, IProgress <double> progress)
        {
            return(Task.Run(() =>
            {
                if (string.IsNullOrEmpty(outputFile))
                {
                    throw new ArgumentNullException("outputFile");
                }

                using (Stream stream = new ProgressionStream(this.Download(uri), progress, this.ReportProgressChunkSize))
                {
                    this.SaveStream(stream, outputFile);
                }
            }));
        }
Пример #4
0
        public Task DownloadFileAsync(Uri uri, string outputFile, IProgress <double> progress = null, CancellationToken?cancellationToken = null)
        {
            return(Task.Run(() =>
            {
                if (string.IsNullOrEmpty(outputFile))
                {
                    throw new ArgumentNullException("outputFile");
                }

                using (Stream stream = new ProgressionStream(Download(uri, cancellationToken), progress, _options.ReportProgressChunkSize))
                {
                    SaveStream(stream, outputFile);
                }
            }, cancellationToken.GetValueOrDefault()));
        }