dqcqcqwq38860 2015-06-05 22:03
浏览 56

在几GB之后,Resumable Upload会被干扰

I have a function in php to upload several files through a stand alone script, the first ones upload fine but the last one that's 16GB around 20 minutes it gets interrumpted for no reason and the upload stops. The auth is already handled, so I don't know what may be causing this issue. Here's the code and the error that it outputs:

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);

}

Error:

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
  • 写回答

1条回答 默认 最新

  • dounianxie2058 2015-06-08 21:20
    关注

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

    The problem is in the Stream library, inside the IO folder. "As a temporary workaround, try commenting out the following clause from IO/Stream.php at line 107:"

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

    EDIT: Still didn't work, trying with the MediaFileUpload hotfix of doing the following code in lines 240~ish:

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

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大