简体   繁体   English

有没有办法使用pydrive将整个文件夹上传到谷歌驱动器?

[英]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.

相关问题 使用PyDrive将大文件上传到Google云端硬盘 - Upload a huge file to Google Drive using PyDrive 使用 PyDrive 将图像上传到 Google Drive - Upload Image to Google Drive using PyDrive 使用PyDrive将文件上传到Google-Drive Teamdrive文件夹 - Upload File to Google-drive Teamdrive folder with PyDrive 使用 pydrive 将文件上传到共享 Google Drive 中的共享文件夹时出现“不允许的方法” - 'Method Not Allowed' when using pydrive to upload files to a shared folder in a shared Google Drive 使用PyDrive将Pandas DataFrame作为Excel文件直接上传到Google云端硬盘 - Upload a Pandas DataFrame as Excel file directly to Google Drive using PyDrive 如何在 python 中使用 pydrive 在谷歌驱动器中查找子文件夹 ID - How to find the sub folder id in google drive using pydrive in python 使用 PyDrive 列出共享的 Google Team Drive 文件夹中的所有文件 - List all files in folder in shared Google Team Drive using PyDrive 使用 pydrive 将图像字符串上传到 Google Drive - Uploading image string to Google Drive using pydrive 如果文件夹已存在于谷歌驱动器中,如何跳过文件夹创建? (PyDrive) - How to skip folder creation if the folder already exists in google drive? (PyDrive) pydrive:尝试将文件从远程服务器上传到 Google Drive - pydrive: trying to upload files to Google Drive from a remote server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM