google Drive v2 Resumable Uploading php api

212 views Asked by At

I'm reading description for resumable download to Gdrive but not founded any workable example for v2 API https://developers.google.com/drive/v2/reference/files/insert

How modify this code for resumable uploading big size files for google api ver-2 client ver 0.6.0.tar.gz

<?
//  including api library
require_once 'src/Google_Client.php';
require_once 'src/contrib/Google_DriveService.php';
require_once 'src/io/Google_HttpRequest.php';


function insertFile($service, $title, $description, $parentId, $mimeType, 
$filename) {
$file = new Google_Service_Drive_DriveFile();
$file->setTitle($title);
$file->setDescription($description);
$file->setMimeType($mimeType);

// Set the parent folder.
if ($parentId != null) {
$parent = new Google_Service_Drive_ParentReference();
$parent->setId($parentId);
$file->setParents(array($parent));
  }

try {
$data = file_get_contents($filename);

$createdFile = $service->files->insert($file, array(
'data' => $data,
'mimeType' => $mimeType,
));

 // Uncomment the following line to print the File ID
 // print 'File ID: %s' % $createdFile->getId();

  return $createdFile;
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
}

?>
0

There are 0 answers