Reputation: 1620
As per Single-parenting behavior changes in Google Drive API, beginning Sept. 30, 2020, you will no longer be able to place a file in multiple parent folders. Now we should Create a shortcut to a Drive file instead.
Is it possible to create shortcut to the file with Google Drive PHP Client v2 or anyhow simple with PHP.
I have tryed:
$file = new \Google_Service_Drive_DriveFile();
$file->setName('Shortcut Name');
$file->setParents([$parent_id]);
$file->setMimeType('application/vnd.google-apps.shortcut');
$shortcut = $drive->files->create($file, [
'shortcutDetails' => [
'targetId' => $file_id
]
]);
I'm getting unknown parameter: 'shortcutDetails'
Upvotes: 0
Views: 262
Reputation: 201388
I believe your goal and situation as follows.
In this case, I would like to propose to use setShortcutDetails()
in your script. When your script is modified, it becomes as follows.
$file = new \Google_Service_Drive_DriveFile();
$file->setName('Shortcut Name');
$file->setParents([$parent_id]);
$file->setMimeType('application/vnd.google-apps.shortcut');
$shortcutDetails = new \Google_Service_Drive_DriveFileShortcutDetails();
$shortcutDetails->setTargetId($file_id);
$file->setShortcutDetails($shortcutDetails);
$createdFile = $service->files->create($file);
$parent_id
and $file_id
.Upvotes: 1