I am having serious issues with the documentation for the new google drive API client library. It seems this should be an easy one to answer without having to put it on stac
The following sample will work with the latest version of the Google APIs PHP Client (https://code.google.com/p/google-api-php-client/source/checkout)
if ($client->getAccessToken()) {
$filePath = "path/to/foo.txt";
$chunkSizeBytes = 1 * 1024 * 1024;
$file = new Google_DriveFile();
$file->setTitle('My document');
$file->setDescription('A test document');
$file->setMimeType('text/plain');
$media = new Google_MediaFileUpload('text/plain', null, true, $chunkSizeBytes);
$media->setFileSize(filesize($filePath));
$result = $service->files->insert($file, array('mediaUpload' => $media));
$status = false;
$handle = fopen($filePath, "rb");
while (!$status && !feof($handle)) {
$chunk = fread($handle, $chunkSizeBytes);
$uploadStatus = $media->nextChunk($result, $chunk);
}
fclose($handle);
}