Възобновяемо изтегляне на големи файлове от googledrive

Трябва да създам метод за възобновяеми изтегляния на голям файл от GoogleDrive под акаунт за услуга. Създавам самостоятелно приложение в .Net 4.0, използвайки Google.Apis.Drive.v2, Google.Apis.Auth и Google.Apis.Oauth2.v2.

Текущият ми код е:

DriveService service = new DriveService(new BaseClientService.Initializer() ...
var pathString = System.IO.Path.Combine(localFilePath, fileName);
using (var fileStream = System.IO.File.Create(pathString))
{
    Task<System.IO.Stream> streamTask = service.HttpClient.GetStreamAsync(downloadURL);
    System.IO.Stream stream = await streamTask;
    await stream.CopyToAsync(fileStream);
}

Въпреки това изглежда GetStreamAsync не поддържа посочване на параметър за диапазон.

Някои предложения препоръчват използването на HttpWebRequest:

//Partial downloads: https://developers.google.com/drive/web/manage-downloads
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
    new Uri(file.DownloadUrl));
request.AddRange(1000, 2000);
authenticator.ApplyAuthenticationToRequest(request);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();

Проблемът с това е, че не знам как получавате IAuthenticator удостоверител от DriveService или ServiceAccountCredential. Изглежда също така, че използването на HttpWebRequest е по-бавно.


person DerekB    schedule 29.09.2015    source източник
comment
Подобно на този проблем   -  person lazy    schedule 29.09.2015
comment
Защо не съдите Media Downloader? Повече подробности можете да намерите тук: developers.google.com/api-client- библиотека/дотнет/ръководство/   -  person peleyal    schedule 20.10.2015