小编Raa*_* A.的帖子

使用 PyDrive 将文件上传到 Google-drive Teamdrive 文件夹

我已经成功地使用 PyDrive 将文件上传到 google-drive-folder。但是,当将文件上传到与我共享的 google-drive-teamdrive-folder 中的文件夹时,以下代码不起作用。

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)


location_to_save = "D:\images"
mImageLoc =  location_to_save + "\\abcd.jpg"

#[...Code to fetch and save the file as abcd.jpg ...]

gfolder_id = "1H1gjBKcpiHJtnXKVxWQEC1CS8t4Gswjj"  #This is a google drive folder id. I am replacing this with a teamdrive folder id, but that does not work
gfile_title = mImageLoc.split("\\")[-1] # returns abcd.jpg

http = gdrive.auth.Get_Http_Object()
f = gdrive.CreateFile({"parents": [{"kind": "drive#fileLink", "id": gfolder_id}],
                                   'title': …
Run Code Online (Sandbox Code Playgroud)

python python-3.4 pydrive google-drive-shared-drive

5
推荐指数
1
解决办法
2179
查看次数