在Python中将图像目录上传到Google驱动器的最佳方法 [英] Best way to upload a directory of images to Google drive in python

查看:102
本文介绍了在Python中将图像目录上传到Google驱动器的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像目录,我想通过python脚本将其转移到Google驱动器。

在保留原始目录结构的同时,将图像目录上传(递归)到Google驱动器的好方法是什么?制作这个多线程会有什么好处吗?如果是这样,那将如何工作?

我会在两遍中做到这一点。首先扫描文件夹层次结构,然后重新创建驱动器上的文件夹。使用云端硬盘文件夹ID更新您的内存中文件夹模型。然后扫描你的文件,用适当的父母id上传每个文件。



如果每个线程都有一个唯一的客户端ID,那么只能使它成为多线程。否则,您最终会触发云端硬盘中的速率限制错误。如果您有大量文件,请购买盒装游戏。


I have a directory of images that I'd like to transfer to Google drive via a python script.

What's a good way to upload (recursively) a directory of images to Google drive while preserving the original directory structure? Would there be any benefit to making this multithreaded? And if so, how would that work?

解决方案

I would do this in two passes. Start by scanning the folder hierarchy, and then recreate the folders on drive. Update your in-memory folder model with the Drive folder ids. Then scan your files, uploading each one with appropriate parent id.

Only make it multithreaded if each thread will have a unique client id. Otherwise you will end up triggering the rate limit bug in Drive. If you have a large number of files, buy the boxed set of Game Of Thrones.

这篇关于在Python中将图像目录上传到Google驱动器的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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