[英]File migration via dropbox APi
我正在使用Dropbox API将大量文件从一个Dropbox帐户迁移到另一个帐户。 每个文件大约需要2到7秒。 是否有任何方法可以加快使用Dropbox API移动文件所需的时间?
source = dropbox.Dropbox('connectionstring')
target = dropbox.Dropbox('connectionstring')
list_folder = source.files_list_folder('')
while list_folder:
files = re.findall(r'name=[\'"]?([^\'" >]+)', str(list_folder))
for f in files:
source.files_download_to_file(f,'')
files = open(f,mode='rb')
target.files_upload(files.read(),'')
files.close()
os.remove(f)
list_folder = source.files_list_folder_continue(list_folder.cursor)
是的,您可以使用“复制参考”直接在帐户之间复制文件或文件夹,而无需下载和重新上传文件。 这些是标识一个帐户中内容的字符串,可用于将内容复制到另一个帐户中。
要从源帐户获取对文件或文件夹的副本引用,请使用/ 2 / files / copy_reference / get:
https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-get
要使用这些副本引用将文件或文件夹保存在目标帐户中,请使用/ 2 / files / copy_reference / save:
https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-save
另外,如果由于某种原因而无法使用复制引用,请务必查看《数据入口指南》以获取有关如何更有效地上传文件的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.