예제 #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()));
        }