Closed elrezad closed 1 year ago
Please check this question / answer https://github.com/iterative/PyDrive2/issues/218. I think it's a duplicate.
Hi @shcheklein , thanks for your reply. #218 indeed seems a duplicate, but in reality the original question was another one ("how to read shorcuts"), and then the user changed the title and closed it without a solution:
So I recycle the issue and change its title to "how to create shortcut files", just in case anybody else is interested. But probably, that is not a PyDrive2 issue at all (just a general Gdrive API question). So I'll close the issue as well. For reference, some info here I still didn't try myself using PyDrive2:
The links provided didn't help.
(side question: Should I have reopened #218 instead of creating a new one?)
Thanks again.
Could you try something along these lines (inspired by this answer on SO that is mentioned in one of the issues we mentioned):
meta = {
"name": "A file's Shortcut",
"mimeType": "application/vnd.google-apps.shortcut",
"parents": [
// Optional, unless you want to put shortcut inside of a folder
],
"shortcutDetails": {
"targetId": "<id>",
"targetMimeType": "application/vnd.google-apps.file"
}
}
file = client.CreateFile(meta)
file.Upload()
Overall, CreateFile
is a thin wrapper on top of the files
API, it means for example that the way we create a dir is this:
parent = {"id": parent_id}
item = self.client.CreateFile(
{"title": title, "parents": [parent], "mimeType": FOLDER_MIME_TYPE}
)
item.Upload()
return item
Most likely it means that we should be able to create a shortcut in a similar way, providing the right combination of mimeType
and the needed details.
It works, thanks you so much!
Hi, thanks for your work with this software.
I'm trying to create a shortcut on Google Drive to a Google file, but I couldn't figure out how to do it. Google SDK shows an example, which involves setting the mimetype to 'application/vnd.google-apps.shortcut' and the "shorcut_details" metadata.
Any help?
Thanks!