gpt4 book ai didi

python - pyDrive 给出 FileNotDownloadableError 错误

转载 作者:太空宇宙 更新时间:2023-11-03 17:36:49 24 4
gpt4 key购买 nike

我正在尝试使用 PyDrive 从 Google Drive 下载文件。我按照指示http://pythonhosted.org/PyDrive/filemanagement.html#download-file-content进行操作。它在我自己的域中正常工作。

日志如下。

$ python driveDownload.py

Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F2Fwww.googleapis.com%2Fauth%2Fdrive&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=837780293427-8m0mkibmrn8gg44i77pjg54ga70kpgae.apps.googleusercontent.com&access_type=offline

Authentication successful.
title: a.xlsx, id: 0BzV-wECmF8MQTkdyQ0FHaVdwYlU
file Title identiefied :a.xlsx
aFromDrive.xlsx downloaded

我正在从客户的域中尝试相同的操作,但出现以下错误

$ python driveDownload.py

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=971731530622-7tdt9qhakv6q7i4edpfnqb5h7826eslv.apps.googleusercontent.com&access_type=offline

Authentication successful.
title: a.xlsx, id: 1l073W5s4dE0-dhFUXAMB-XROvOUC2z51NbfY69-bvIo
file Title identiefied :a.xlsx
Traceback (most recent call last):
File "driveDownload.py", line 29, in <module>
myFile.GetContentFile(myLocalPath)
File "build/bdist.linux-x86_64/egg/pydrive/files.py", line 167, in GetContentFile
File "build/bdist.linux-x86_64/egg/pydrive/files.py", line 36, in _decorated
File "build/bdist.linux-x86_64/egg/pydrive/files.py", line 210, in FetchContent
pydrive.files.FileNotDownloadableError: No downloadLink/exportLinks for mimetype found in metadata

我的代码driveDownload.py如下

from pydrive.auth import GoogleAuth
import os
#authentication via the browser
#note... client_secrets.json is required for this that leads
#to the user authentication
gauth = GoogleAuth()
# gauth.LocalWebserverAuth()
from pydrive.drive import GoogleDrive

#accessing the drive
drive = GoogleDrive(gauth)


# Auto-iterate through all files that matches this query
file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList()
fileName2Download= 'a.xlsx'
myLocalPath = 'aFromDrive.xlsx'
for file1 in file_list:
print 'title: %s, id: %s' % (file1['title'], file1['id'])
if file1['title'] == fileName2Download:
print ' file Title identiefied :%s'% (file1['title'])
myFile = drive.CreateFile({'id': file1['id']})
if os.path.exists(myLocalPath):
os.remove(myLocalPath)

myFile.GetContentFile(myLocalPath)
print '%s downloaded ' %(myLocalPath)
break
# file1.download()

是否缺少一些设置?我能够列出客户的谷歌驱动器中的所有文件。但是,当我尝试将文件下载到本地磁盘时出现错误

最佳答案

我收到此错误是因为我尝试直接下载文件夹。仔细检查您的 mimeType 是否可以通过 PyDrive 下载。

关于python - pyDrive 给出 FileNotDownloadableError 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31108339/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com