My intention is to be able to upload a new version of the file which is already available on Google Drive.
I've started by the PHP example at 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;
}
}
As a result I get
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."
}
}
I don't get what are the not-writable fields in question. The only thing I'm changing is the actual content of the file, none of it's metadata.
Any ideas what's wrong?