GoogleDrive FilesResource.UpdateMediaUpload不报告进度,仅报告开始/完成



我设置了以下代码来显示上传文件的进度:

FilesResource.UpdateMediaUpload updateRequest = service.Files.Update(myFile, fileID, stream, myFile.MimeType);
updateRequest.ProgressChanged += (s) =>
            {
                Console.WriteLine();
                Console.WriteLine("Progress Update");
                if (m_oWorker.IsBusy)
                {
                    int percent = (int)(100 * ((Double)s.BytesSent / maxLength));
                    Console.WriteLine("Sending Bytes: " + s.BytesSent.ToString());
                    Console.WriteLine("Sending Bytes percent: " + percent.ToString());
                    m_oWorker.ReportProgress(percent);
                }
            };
            updateRequest.Upload();

结果如下:

Progress Update
Sending Bytes: 0
Sending Bytes percent: 0
Progress Update
Sending Bytes: 7199570
Sending Bytes percent: 100

工作正在后台工作线程中完成,但我认为这不应该影响它?

我是不是有什么事没做?

引用。net客户端库中媒体上传的文档:

进度更改通知将在上传开始时调用,在每个上传块时调用,在成功或失败时调用。

关于块大小:

默认的块大小是10MB,但是您可以通过在请求中设置ChunkSize属性为256KB的任意倍数来更改它。

最新更新