通过Dropbox APi进行文件迁移 [英] File migration via dropbox APi

查看:140
本文介绍了通过Dropbox APi进行文件迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Dropbox API将大量文件从一个Dropbox帐户迁移到另一个帐户。每个文件大约需要2到7秒。是否有任何方法可以加快使用Dropbox API移动文件所需的时间?

I'm using the dropbox API to migrate a large amount of files from one dropbox account to another. This seems to be taking between 2 and 7 seconds per file. Are there any ways to speed up the time it takes to move files using the 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)


推荐答案

是的,您可以使用复制引用直接在帐户之间复制文件或文件夹,而无需下载和重新上传文件。这些是用于标识一个帐户中内容的字符串,可用于将内容复制到另一个帐户中。

Yes, you can copy files or folders between accounts directly, without downloading and re-uploading the files, by using "copy references". These are strings that identify content in one account, and can be used to copy that content to another account.

要从源帐户获取对文件或文件夹的副本引用,使用/ 2 / files / copy_reference / get:

To get copy references to files or folders from the source account, use /2/files/copy_reference/get:

https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-get

要使用这些副本引用将文件或文件夹保存在目标帐户中,请使用/ 2 / files / copy_reference / save:

To use those copy references to save the files or folders in the target account, use /2/files/copy_reference/save:

https://www.dropbox.com/developers/documentation/http/documentation#files- copy_reference-save

或者,如果由于某种原因不能使用复制引用,请务必签出数据入口指南,以获取有关如何更有效地上传文件的信息。

Alternatively, if you can't use copy references for some reason, be sure to check out the Data Ingress Guide for information on how to more efficiently upload files.

这篇关于通过Dropbox APi进行文件迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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