public async Task UploadFile(UploadSession session, long position, Stream dataStream, IProgress<double> progress, CancellationToken cancelToken = default(CancellationToken)) { if (dataStream == null) { throw new ArgumentNullException("dataStream"); } byte[] buffer = new byte[CHUNK_SIZE]; var httpClient = new HttpClient(); dataStream.Seek(position, SeekOrigin.Begin); int readed = 0; while ((readed = dataStream.Read(buffer, 0, buffer.Length)) != 0) { System.Diagnostics.Debug.WriteLine("Content-Lenght:{0}", CHUNK_SIZE.ToString()); System.Diagnostics.Debug.WriteLine("Content-Range: {0}", string.Format("bytes {0}-{1}/{2}", position, dataStream.Position - 1, dataStream.Length)); var message = CreateChunkMessage(position, dataStream.Position - 1, dataStream.Length, buffer, session.Location); var response = await SendMessage(httpClient, message, cancelToken); position = dataStream.Position; if (progress != null) { progress.Report((position / (double)dataStream.Length) * 100); } if (cancelToken.IsCancellationRequested) { break; } } }
public Task AbortUpload(UploadSession session) { return _fileUploader.AbortUpload(session); }
public Task ResumeUpload(UploadSession session, Stream dataStream, IProgress<double> progress, CancellationToken cancelToken = default(CancellationToken)) { return _fileUploader.ResumeUpload(session, dataStream, progress, cancelToken); }
public async Task ResumeUpload(UploadSession session, Stream dataStream, IProgress<double> progress, CancellationToken cancelToken = default(CancellationToken)) { if (session == null) { throw new ArgumentNullException("session"); } var position = await GetBrokenUpload(dataStream, session.Location); await ResumeUpload(session, position, dataStream, progress, cancelToken); }
public async Task ResumeUpload(UploadSession session, Stream dataStream) { var position = await GetBrokenUpload(dataStream, session.Location); await ResumeUpload(session, position, dataStream, null); }
public Task ResumeUpload(UploadSession session, long position, Stream dataStream) { return ResumeUpload(session, position, dataStream, null); }
public Task UploadFile(UploadSession session, Stream dataStream, CancellationToken cancelToken) { return UploadFile(session, 0, dataStream, null, cancelToken); }
public Task UploadFile(UploadSession session, Stream dataStream, IProgress<double> progress) { return UploadFile(session, 0, dataStream, progress); }
public Task UploadFile(UploadSession session, Stream dataStream) { return UploadFile(session, dataStream, null); }
public async Task AbortUpload(UploadSession session, CancellationToken cancelToken = default(CancellationToken)) { var message = new HttpRequestMessage(HttpMethod.Delete, session.Location); await SendMessage(message, cancelToken); }
public Task ResumeUpload(UploadSession session, long position, Stream dataStream, IProgress<double> progress, CancellationToken cancelToken = default(CancellationToken)) { return UploadFile(session, position, dataStream, progress, cancelToken); }