Reputation: 21
I have a folder in Google Drive, and I try to place its shotcuts in several other folders (just organizing my data by tags, e.g. put "Holiday photos" shortcuts in folders "Holidays" and "Photos"). I can easily create a shortcut with:
'mimeType': 'application/vnd.google-apps.shortcut'
These shortcuts work great only on Web Application, but I am using desktop "Backup & Sync", where all these shortcuts become files .gshortcut and open as web links.
It seems that shortcuts were working in good old days, but on august of last year Google published this:
https://workspaceupdates.googleblog.com/2020/08/expanding-shortcuts-google-drive.html
When using Drive on the web, the keyboard shortcut Shift+Z on a shared file used to place the file in multiple locations. Now, when a single file or multiple items are selected, Shift+Z will create a shortcut instead. However, if a single folder is selected, Shift-Z will still add another location for the folder to ensure continued compatibility with offline access via Backup and Sync.
Keyboard shortcut Shift+Z is working great, and it realy creates adequate Windows-friendly shortcuts, but I found no information about this function in Google Drive API Documentation, and moreover, the MIME type of this shortcut is:
'mimeType': 'application/vnd.google-apps.folder'
And I feel this means nothing positive.
MIME types: https://developers.google.com/drive/api/v3/mime-types
I found the official name of this operation:
Instead of a shortcut, add the folder to an additional location. On the Google Drive website, select the folder and press Shift + Z.
But found even less information about it
And, at last, I found the information about Google Drive API update:
A request that creates a new item can no longer specify multiple parents.
So I am 99% sure that this can't be done anymore, but anyway:
Are there any way to create these "Shift+Z" shortcuts with Google Drive API?
Upvotes: 2
Views: 1911
Reputation: 5953
When creating a shortcut to a Drive file, you just need to set the following:
mimeType
= application/vnd.google-apps.shortcut
targetId
= file id/folder id that the shortcut will point to.name
= shortcut file nameparents
= (Optional) folder id where you want the shortcut to be placed.Sample Request Body:
{
"name": "Test Assignment 3-Shortcut",
"mimeType": "application/vnd.google-apps.shortcut",
"parents": [
"1TrX6KcAJppWCj9GSUjSYn79AqJ1xxxx"
],
"shortcutDetails": {
"targetId": "0B8xt-68OtkVWfl9OMW5fcjV4RWJsWExRU3B0M0d6SlNacWwyTHZ2cUhoNE1IZ096exxxx"
}
}
Output
Upvotes: 3