我可以通过json在Google云端硬盘中创建一个文件到Drive文件夹中:
$data = array(
"title" => $_FILES['file']['name'],
"parents" => array(array(
"kind" => "drive#parentReference",
"id" => $parent_id
)),
"mimeType" => "application/pdf"
);
$data = json_encode($data);
$url = "https://www.googleapis.com/drive/v2/files?oauth_token=".$accessToken;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
Run Code Online (Sandbox Code Playgroud)
但是我找不到在其上添加PDF文件的方法,因为在Google云端硬盘文档中没有指定json属性.
我在哪里添加文件内容?这可能吗?
我是否必须将文件上传到上传/驱动器,然后上传文件夹ID的元数据?我没有找到感觉.