尝试转移所有权时,出现以下错误:
"domain": "global",
"reason": "invalidSharingRequest",
"message": "Bad Request. User message: \"You can't change the owner of this item.\""
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
use Google_Client;
use Google_Service_Drive;
use Google_Service_Drive_DriveFile;
use Google_Service_Drive_Permission;
public function uploadDocument() {
$FOLDER_ID = 'my_folder_ID_string';
$client = new Google_Client();
$client->setAuthConfig(base_path('service_account_credentials.json'));
$client->setScopes(array('https://www.googleapis.com/auth/drive'));
$service = new Google_Service_Drive($client);
$fileMetadata = new Google_Service_Drive_DriveFile(array(
'name' => 'Test.pdf',
'parents' => [$FOLDER_ID]
));
$content = file_get_contents(public_path('tmp/Test.pdf'));
$file = $service->files->create($fileMetadata, array(
'data' => $content,
'mimeType' => 'application/pdf',
'uploadType' => 'multipart',
'fields' => 'id'
));
// Transfer Ownership
$newPermission = …Run Code Online (Sandbox Code Playgroud)