【发布时间】:2014-11-13 07:38:34
【问题描述】:
我正在尝试使用python script 更新Google drive 中的现有文件。
我使用的代码是:
fileID = wasFileUploadedBefore(drive, reportName) #this gets the fileID if it's already in GDrive
if fileID != 0:
reportFile = drive.CreateFile({'id': fileID})
else:
reportFile = drive.CreateFile({'title':reportName, 'mimeType':'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
reportFile.SetContentFile(reportName)
reportFile.Upload({'convert':True}) #convert=true is to convert the file to GoogleDrive Spreadsheet.
正如我所说,当我运行代码时会发生以下错误:
raise ApiRequestError(error)
ApiRequestError: <HttpError 500 when requesting https://www.googleapis.com/upload/drive/v2/....&convert=true&alt=json returned "Internal Error">
如果我在 Upload 中不使用 {'convert':True} 标签,一切都很好,但我真的需要它,因为我想转换文件。
我正在尝试上传 .xlsx 文件
【问题讨论】:
-
尝试:({'convert':true})
-
It
s not working. Ive 也尝试过 ({'convert':'true'}) -
有什么理由不使用 Google 的示例和客户端库?
-
如果找不到解决方案,我会尝试 google-api。我真的很好奇为什么这不起作用
-
可能您使用的代码中的某些内容 Google 没有上传其插入内容。因此,无法知道该代码是否支持转换。你在那里。
标签: python python-2.7 google-drive-api pydrive