如何将 alt=media 与 Google 驱动器 Python API 一起使用?

How to use alt=media with Google Drive Python API?

这是一种方法(基于 Google 驱动器 Python quickstart.py)使用 Python [=48] 从 Google 驱动器下载文件=]:

credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('drive', 'v2', http=http)

request = service.files().get_media(fileId=file_id)
fh = io.FileIO(file_name, 'wb')
downloader = MediaIoBaseDownload(fh, request, chunksize=1024*1024)

done = False
while done is False:
    status, done = downloader.next_chunk()
    if status:
        print("download progress: {} %".format(int(status.progress() * 100)))
print("download complete!")

这会将文件 ID 为 file_id 的 Drive 文件写入名称为 file_name 的本地文件。

然而,documentation 一遍又一遍地说 "preferred method" 是使用 "alt=media"。

alt=media 如何与 files().get() 一起使用? alt=media 去哪儿了?它有什么作用?

任何人都可以提供一个简单的示例来说明如何使用 files().get() 和 alt=media 下载文件吗?

或者... "use files().get() with alt=media" 只是意味着使用 files().get_media() ?!

感谢任何能提供明确解释的人!

Gerardo 的评论很贴切,基本上就是我所怀疑的。结案。并感谢您指出 OAuth 游乐场。