我的意圖是能夠上載Google雲端硬盤中已有的新版本文件。Google_Service_Exception:在Google雲端硬盤上上傳文件新版本時的fieldNotWritable
我已經從PHP示例https://developers.google.com/drive/v2/reference/files/update#examples開始了。
function updateFile($fileID, $uploadFile) {
try {
$file = $this->service->files->get($fileID);
$content = file_get_contents($uploadFile);
$file = $this->service->files->update($fileID, $file, array(
'data' => $content,
));
printf("Updated File ID: %s\n", $file->getId());
} catch (Exception $e) {
echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
}
}
結果我得到
Google_Service_Exception: {
"error": {
"errors": [
{
"domain": "global",
"reason": "fieldNotWritable",
"message": "The resource body includes fields which are not directly writable."
}
],
"code": 403,
"message": "The resource body includes fields which are not directly writable."
}
}
我不明白什麼是有問題的不是寫的領域。我正在改變的唯一事情就是文件的實際內容,而不是它的元數據。
任何想法有什麼不對?
可能與API的v3中的更改有任何關係? – Slawa