/*
Copyright 2013 Google Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Google.Apis.Download
{
/// Media download which uses download file part by part, by .
public interface IMediaDownloader
{
/// An event which notifies when the download status has been changed.
event Action ProgressChanged;
/// Gets or sets the chunk size to download, it defines the size of each part.
int ChunkSize { get; set; }
/// Downloads synchronously the given URL to the given stream.
IDownloadProgress Download(string url, Stream stream);
/// Downloads asynchronously the given URL to the given stream.
Task DownloadAsync(string url, Stream stream);
///
/// Downloads asynchronously the given URL to the given stream. This download method supports a cancellation
/// token to cancel a request before it was completed.
///
///
/// In case the download fails will contain the exception that
/// cause the failure. The only exception which will be thrown is
/// which indicates that the task was canceled.
///
Task DownloadAsync(string url, Stream stream, CancellationToken cancellationToken);
}
}