Python google drive API 下载,文件在哪里?
问题描述
我使用此处找到的 python 代码下载了谷歌驱动器上的文件:https://developers.google.com/drive/v3/web/manage-downloads我有这个范围:https://www.googleapis.com/auth/drive一切似乎都有效,我读到:
I used the python code found here to download a file on google drive: https://developers.google.com/drive/v3/web/manage-downloads I have this scope: https://www.googleapis.com/auth/drive everything seems to work, I read:
Download 35%.
Download 71%.
Download 100%.
但是文件在哪里?在与python文件相同的目录中,没有任何东西,既不是根目录,也不是主目录……你有想法吗?或者我该如何调试?
but where is the file? in the same directory as the python file, there is nothing, neither the root, nor in the home ... you have ideas? or alternatively how can I debug?
解决方案
Google doc 使用示例
Example in Google doc uses
fh = io.BytesIO()
所以它将数据读入内存,而不是保存在磁盘上.
so it reads data into memory and it doesn't save on disk.
您必须使用(例如)保存它
You have to save it using (for example)
open(..., 'wb')
write(fh)
close()
<小时>
编辑:其他人的信息 - 正如@michelle.70 发现的那样 - 我们可以使用
EDIT: information for others - as @michelle.70 found - we can use
fh = io.FileIO(filename, 'wb')
而不是 fh = io.BytesIO()
相关文章