簡體   English   中英

通過Dropbox APi進行文件遷移

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM