![](/img/trans.png)
[英]How can I download files from a Github repository without logging in?
[英]How can I download files from team drives?
我想定期從谷歌驅動器上的共享團隊驅動器下載和上傳文件。 我可以上傳到文件夾,但不能下載。
這是我嘗試過的
team_drive_id = 'YYY'
file_to_download= 'ZZZ'
parent_folder_id = 'XXX'
f = drive.CreateFile({
'id':file_to_download,
'parents': [{
'kind': 'drive#fileLink',
'teamDriveId': team_folder_id,
'id': parent_drive_id
}]
})
f= drive.CreateFile({'id': file_to_download})
f.GetContentFile('test.csv', mimetype='text/csv')
但這就是我得到的:
ApiRequestError: <HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/file_to_download?alt=json returned "File not found: file_to_download">
有什么建議么?
遵循可以在此處查看的文檔
首先創建文件:
f = drive.CreateFile({'id': file_to_download})
然后你在文件上設置內容
f.SetContentString("whatever comes inside this file, it is a csv so you know what to expect to be here")
並完成你需要做的上傳
f.Upload()
之后,文件在那里正確創建,您可以使用GetContentString
方法讀取它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.