可以同时在Google Drive API上建立的连接数是否有限制?

时间:2018-12-29 11:24:24

标签: c# multithreading tcp google-drive-api

我正在使用Google Drive API在多个线程中上传图像。它正在工作,但是当我查看该过程时,八个线程只有两个或三个TCP连接。

我想改善上传。

同时连接到Google云端硬盘是否有限制?

我的代码:

List<Task> tasks = new List<Task>();
foreach (ImageToUploadDto fileName in bindImagensToUpload.List)
{
    var task = UploadFileAsync(fileName.CompletePathFileName, "AlbumDigital", progress);

    tasks.Add(task);
}

await Task.WhenAll(tasks);

MessageBox.Show("Done!");

public Task<IUploadProgress> UploadFileAsync(string LocalPath)
{   //create a file and associate with a folder
    var file = CreateGDriveFile(System.IO.Path.GetFileName(LocalPath));

    FilesResource.CreateMediaUpload request;
    var stream = new System.IO.FileStream(LocalPath, System.IO.FileMode.Open);
    request = driveService.Files.Create(file, stream, "image/jpeg");
    request.ChunkSize = ResumableUpload.MinimumChunkSize * 4;

    request.Fields = "id, webContentLink, name";

    var task = request.UploadAsync();
    task.ContinueWith(t =>
    {
        stream.Dispose();
    });

    return task;
}

0 个答案:

没有答案