Note: Although Google has a working system for batch requests, it does not appear to be compatible with requests involving media. So far, I've only been able to get it to work with File objects, which do not consist of media content.
Below is my current code used to download media from a Drive folder. Note that all of the media consist of simple tiny rtf documents, and so you should have an idea of the file sizes. My issue is that even though the files download as expected, it is a SLOW process! I have a folder consisting of more than 300 files on average. There has to be a way to speed up this process.
private async void Button_Click()
{
foreach (var driveFile in driveFileList)
{
await GetFileContentAsync(driveFile.Id, CancellationToken.None);
}
}
public async Task<AccessResult> GetFileContentAsync (string driveId, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested ();
GetRequest getRequest = new GetRequest (DriveService, driveId);
getRequest.Fields = "*";
string incomingJsonContent;
try
{
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream ())
using (System.IO.StreamReader streamReader = new System.IO.StreamReader (memoryStream))
{
IDownloadProgress downloadProgress = await getRequest.DownloadAsync (memoryStream, cancellationToken);
memoryStream.Position = 0;
incomingJsonContent = await streamReader.ReadToEndAsync ();
}
return new AccessResult (true, incomingJsonContent);
} catch {}
}