可恢复上传在几GB后被中断


Resumable Upload gets interrumpted after few GB

我在php中有一个函数,通过一个独立的脚本上传几个文件,第一个上传的很好,但最后一个是16GB左右的20分钟,它被无故中断,上传停止。auth已经处理了,所以我不知道是什么原因导致了这个问题。下面是代码和它输出的错误:

function insertFile($client,$service,$filePath,$name,$fId){
    $file = new Google_Service_Drive_DriveFile();
    $file->title = $name;       
    $parent = new Google_Service_Drive_ParentReference();
    $parent->setId($fId);
    $file->setParents(array($parent));
    $chunkSizeBytes = 1 * 1024 * 1024;

    $client->setDefer(true);
    $request = $service->files->insert(
        $file,
        array(
            'uploadType'=> 'resumable'
        )
    );
    $finfo= finfo_open(FILEINFO_MIME_TYPE);


    $media = new Google_Http_MediaFileUpload(
          $client,
          $request,
          finfo_file($finfo, $filePath),
          null,
          true,
          $chunkSizeBytes
    );

    $media->setFileSize(filesize($filePath));
    $status = false;
    $handle = fopen($filePath, "rb");
    while (!$status && !feof($handle)) {
        $chunk = fread($handle, $chunkSizeBytes);
        $status = $media->nextChunk($chunk);
    }

    $result = false;
    if($status != false) {
        $result = $status;                          
    }
    fclose($handle);
    $client->setDefer(false);
}
错误:

PHP Fatal error:  Uncaught exception 'Google_IO_Exception' with message 'HTTP Error: Unape=resumable&upload_id=AEnB2UoRrzX46hJ02lIDkCJi03MFbE2KVP2LDCBOgnuiclONk3sBvSctZxW3NxsWt /libs/google-api-php-client/src/Google/IO/Stream.php
Stack trace:
#0 /libs/google-api-php-client/src/Google/IO/Abstract
#1 /libs/google-api-php-client/src/Google/Http/MediaF
#2 /root/name.php(199): Google_Http_MediaFileUpload->nextChunk(
#3 /root/name.php(102): insertFile(Object(Google_Client), /libs/google-api-php-client/src/Google/IO/Stream.php on l

根据:https://gae-php-tips.appspot.com/2013/12/23/getting-started-with-the-cloud-datastore-on-php-app-engine/

问题在流库中,在IO文件夹内。作为一个临时的解决方案,尝试在IO/Stream.php的第107行注释掉以下子句:"

if (!$this->client->getClassConfig("Google_Http_Request", "disable_gzip")) {
    $url = self::ZLIB . $url;
}

编辑:仍然没有工作,尝试用MediaFileUpload热修复做以下代码在第240~ish行:

 private function transformToUploadUrl()
  {
    $base = 'https://www.googleapis.com';   //Hardcoded, cambiar si 
    $this->request->setBaseComponent($base . '/upload');
  }