{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: xxxx",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: xxxx"
}
}
有一个要求:
$service = new Google_Service_Drive($google);
$postBody = new Google_Service_Drive_DriveFile([
'name' => $fileOpt['fileName'],
'parents' => array(self::$FOLDER_ID)
]);
$content = $service->files->create($postBody, [
'data' => $fileOpt['data'],
'mimeType' => 'application/json',
'uploadType' => 'media'
]);
return $content;
我允许:
https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.metadata
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
那么为什么 GoogleApi看不到我要上传文件的文件夹呢?我通过 Google API Explorer提出了同样的请求,它可以工作!
请求正文浏览器 API:
"parents": [
"xxxx"
],
"name": "EXAMPLE_FILE_1",
"mimeType": "application/json",
"description": "This is a json file."
所需权限:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.file
我很困惑。帮助!
一切都是正确的。这不是关于代码,而是关于文件夹。我必须让它公开可写并且它起作用了。但是,这不适合我。如果您知道如何在不打开访问权限的情况下执行此操作,那么我正在等待答案。