将文件从Colab上载到Google Drive文件夹 [英] Upload File From Colab to Google Drive Folder

查看:908
本文介绍了将文件从Colab上载到Google Drive文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文件从colab上传到我的Google驱动器中的特定文件夹.我可以使用文件夹ID和以下代码段获取该文件夹:

I want to upload a file from colab to a specific folder in my google drive. I can get the folder by using the folder id and below snippet:

my_folder = drive.ListFile(
        {'q': "'1QYaM1vaUvdzbdsfWbsolncz1xc2pgnpextuP' in parents"}).GetList()

但是我的问题是:如何将文件(图像)上传到此文件夹?是否有

But my question: how do I upload a file(image) to this folder? Is there a function such as

my_folder.upload(my_file)?

my_folder.upload(my_file)?

到目前为止,我已经看到一些有关zip文件的示例,但我不想将其作为zip文件上传.

So far I have seen some examples with zip files but I do not want to upload it as a zip file.

推荐答案

我从此答案

fid = '1QYaM1vaUvdzbdsfWbsolncz1xc2pgnpextuP'
f = drive.CreateFile({"parents": [{"kind": "drive#fileLink", "id": fid}]})
f.SetContentFile( some_path )
f.Upload()

这篇关于将文件从Colab上载到Google Drive文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆