1

我正在阅读可恢复下载到 Gdrive 的说明,但没有为 v2 API https://developers.google.com/drive/v2/reference/files/insert找到任何可行的示例

如何修改此代码以恢复为 google api ver-2 客户端版本 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();
  }
}

?>
4

0 回答 0