iterative / PyDrive2

Google Drive API Python wrapper library. Maintained fork of PyDrive.
https://docs.iterative.ai/PyDrive2
Other
571 stars 70 forks source link

GDriveFileSystem support for shared files / shortcuts #236

Open simone-viozzi opened 1 year ago

simone-viozzi commented 1 year ago

Hi, does GDriveFileSystem support manipulation of files in the shared with me folder? Like copy from my drive to a folder shared with me.

If not, I can create a shortcut in my drive and use the shortcut as path for the file / folder?

From the tries I have done, the second option doesn't work, GDriveFileSystem does not take care of getting the targetId of the shortcut etc..

I would like shortcut to be transparent proxies to the real file / folder, so that for example ls on the shortcut of a folder give me the content of it. Things get complicated with other methods like:

Reference:

aripollak commented 11 months ago

I don't think PyDrive2 currently supports this functionality automatically, but it would be great if it did. Having a method like this on GoogleDriveFile would be super helpful as a start:

    def FollowShortcut(self):
        if self["mimeType"] == "application/vnd.google-apps.shortcut":
            self.FetchMetadata(fields="shortcutDetails")
            return GoogleDriveFile(self.auth, {"id": gdrive_file["shortcutDetails"]["targetId"]})
        else:
            return self