[英]is there a way to upload an entire folder to google drive using pydrive?
I'm doing a python script which periodically upload a folder to Google Drive, but got stuck when I had to load subfolders.我正在做一个 python 脚本,它会定期将文件夹上传到 Google Drive,但是当我不得不加载子文件夹时卡住了。 Is there any way to upload an entire folder?
有没有办法上传整个文件夹?
Maybe with a loop but I have no idea how to do it.也许有一个循环,但我不知道该怎么做。
Below is an example of a folder to upload:以下是要上传的文件夹的示例:
root\
root\image.png
root\Folder1\text.txt
root\Folder1\music.mp3
root\Folder2\MyFolder\homeworks.txt
root\Folder2\Something\something.txt
I'm using PyDrive.我正在使用 PyDrive。
A simpler workaround is to just zip the file:一个更简单的解决方法是压缩文件:
shutil.make_archive('data', 'zip', 'output')
file = drive.CreateFile({'title': 'data.zip'})
file.SetContentFile('data.zip')
file.Upload()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.