Files updates no longer works using the google-api-php-client -


i have small script uploads , / or update files (wrote 1 year ago, borrowed 80% of lines examples)

no major changes in code since march (using 1.0.0-alpha) mid-may file updates stopped working, raising internal server error , upgraded 1.0.4-beta no success :

php fatal error:  uncaught exception 'google_service_exception' message 'error calling put https://www.googleapis.com/upload/drive/v2/ [...] (500) internal error' in  google-api-php-client-1.0.4-beta/src/google/http/rest.php:80 

code:

$client->setdefer(true); $request = $service->files->update($update_id,$file);  $media = new google_http_mediafileupload(     $client,     $request,     'text/plain',     null,     true,     $chunksizebytes ); $media->setfilesize(filesize($csvfile)) $status = false; $handle = fopen($csvfile, "rb"); while (!$status && !feof($handle)) {     $chunk = fread($handle, $chunksizebytes);     $status = $media->nextchunk($chunk); } 

file inserts (http post) still working (using same code uploading chunks)

any ideas ?

i can update file ( created or copied template ) code :

     (...)      require_once 'src/google/client.php';      require_once 'src/google/service/oauth2.php';      require_once 'src/google/service/drive.php';          (...)       $client = new google_client();      // set scopes ...      (...)       $gdrive_service = new google_service_drive($client);      (...)        // set parameters          (...)         $newtitle = $title ;         $newdescription = $description ;         $newmimetype = 'text/csv' ;         $newfilename = $filename ;         $service = $gdrive_service ;         (...)    $updatedfile = updatefile($service, $fileid, $newtitle, $newdescription, $newmimetype, $newfilename, $newrevision) ;   function updatefile($service, $fileid, $newtitle, $newdescription, $newmimetype, $newfilename, $newrevision) {   try {     // first retrieve file api.     $file = $service->files->get($fileid);      // file's new metadata.     $file->settitle($newtitle);     $file->setdescription($newdescription);     $file->setmimetype($newmimetype);      // file's new content.     $data = file_get_contents($newfilename);     $convert = 'true' ;      $additionalparams = array(       'uploadtype' => 'multipart',       'newrevision' => $newrevision,       'data' => $data,       'mimetype' => $newmimetype,       'convert' => $convert,     );      // send request api.     $updatedfile = $service->files->update($fileid, $file, $additionalparams);     return $updatedfile;   } catch (exception $e) {     print "an error occurred: " . $e->getmessage();   } }   (...) // info of updated file  $fileid = $updatedfile->getid() ; // link of file $cf_link = $updatedfile->alternatelink ; // pdf version $enllacos = $updatedfile->exportlinks ; $cf_pdf_link = $enllacos['application/pdf'] ; (...) 

this code working 1.0.5-beta php client

sergi


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -