2016-08-23 84 views
1

我使用node.js和保管箱包從文件夾下載文件。我能夠驗證並列出文件,但不能下載它們。我希望能夠下載沒有共享的文件。從保管箱文件夾下載文件

 client.filesListFolder({ path: directory }) 
    .then(function (response) { 
     response.entries.forEach(function (entry) { 
      if (entry[".tag"] === "file") { 
       client.filesDownload({ url: entry.path_display}) 
        .then(function (data) { 
         // ... 
        }) 
        .catch(function (err) { 
         throw err; 
        }); 
      } 
     }); 
    }) 
    .catch(function (err) { 
     me.ThrowError(null, err.status, err.error); 
    }); 
+1

它看起來就像你使用[dropbox-sdk-js](https://github.com/dropbox/dropbox-sdk-js)並且已經找到['filesDownload'](https://dropbox.github.io/ dropbox-sdk-js/Dropbox.html#filesDownload)方法。什麼是不正確的工作?你有錯誤嗎? – Greg

回答

0

閱讀此鏈接: https://blogs.dropbox.com/developers/2015/04/a-preview-of-the-new-dropbox-api-v2/

filesDownload(網址:{url:entry.path_display})傳遞一個錯誤的ARG。

我覺得應該是{路徑:entry.path_display}

我其實只是嘗試過,但我只得到文件對象,我不知道如何讓文件數據被下載。這可能是因爲我使用Electron.js

在他們的GitHub的問題討論: https://github.com/dropbox/dropbox-sdk-js/issues/88

因此,你可以嘗試使用功能filesGetTemporaryLink({ path: entry.path_display})到一個臨時鏈接,然後使用sharingGetSharedLinkFile({ url: res.link })