Resuming download interrupts after several GB

I have a function in php to upload multiple files through a stand-alone script, the first ones are loaded in order, but the last one, which is 16 GB for about 20 minutes, is interrupted for no reason and the download stops. Auth has already been processed, so I don’t know what might cause this problem. Here's the code and the error 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
source share
1 answer

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

Stream, IO. " , IO/Stream.php 107:"

if (!$this->client->getClassConfig("Google_Http_Request", "disable_gzip")) {

    $url = self::ZLIB . $url;

}

EDIT: , MediaFileUpload 240 ~ ish:

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

All Articles