Python Google Drive API V3导出_媒体缺少内容长度和内容范围
我正在使用Google驱动程序API python库下载CSV格式的文件Python Google Drive API V3导出_媒体缺少内容长度和内容范围,python,google-drive-api,Python,Google Drive Api,我正在使用Google驱动程序API python库下载CSV格式的文件 google_drive_service = get_service() mimeType = 'text/csv' request = google_drive_service.files().export_media(fileId='abc', mimeType=mimeType) fh = io.BytesIO() downloader = MediaIoBaseDownload(fh, request) done
google_drive_service = get_service()
mimeType = 'text/csv'
request = google_drive_service.files().export_media(fileId='abc', mimeType=mimeType)
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while not done:
status, done = downloader.next_chunk()
print "Download %d%%." % int(status.progress() * 100)
fh.seek(0)
content = fh.getvalue()
由于它是一个大标签,下载过程按块进行分解。它不断打印“下载0%”。当代码检查下载过程时,我循环了库代码。它始终显示“下载0%”的原因是http响应没有“内容范围”和“内容长度”头,这会导致进程检查问题
如果您有兴趣复制此过程。创建电子表格并填写列“a:E”和行“1:10000”的单元格值。让我知道是否有人有同样的问题,或者有关于为什么会发生这种情况的线索。以下是Gdrive代码:如果http请求请求,http响应将仅具有内容范围头。根据,导出不支持部分下载,仅支持下载 您可以尝试以下几点:- 1.在v2api中,文件资源具有静态exportLinks数组。您可以尝试在适当的链接上进行部分下载。您需要使用相同的凭证来完成自己的REST-get,而不是python库。 1.您可以考虑使用Google电子表格的“发布”功能创建一个可下载的CSV链接