2017-05-09 79 views
0

我想從收集箱的圖像填充我的收藏視圖。Dropbox - IOS-斯威夫特3:無法獲取縮略圖

我想用我的網格視圖(集合視圖)的縮略圖圖像與下面的代碼。

DropboxClientsManager.authorizedClient?.files.getThumbnail(path: filename).response(completionHandler: { (
      response, error) in 

      print(response) 
      print(error) 

}) 

我得到以下錯誤:

Optional([request-id e70dba3b7ee8f0b9bf6b0aa4b19325f0] API route error - { 
".tag" = path; 
path =  { 
    ".tag" = "not_found"; 
}; 
}) 

但是當我嘗試使用這個下面的方法,我得到的錯誤。我不知道我應該回到這個功能,網址getthumbnail:

DropboxClientsManager.authorizedClient?.files.getThumbnail(path: filename, format: .png, size: .w32h32, overwrite: true, destination: { (url, res) -> URL in 

      print(url) 
      print(res) 
      return url 
     }) 

更新: 我們不能在iOS中獲取DROPBOX IMAGES的縮略圖URL嗎?

有沒有人有解決方案?

有什麼建議?

回答

1

如果您想使用API v2 Swift SDK獲取Dropbox中文件的縮略圖,則使用getThumbnail methods之一是正確的方法。

對於getThumbnail(path:format:size:overwrite:destination:),請注意,這會將縮略圖數據寫入您指定的URL。 (也就是說,它不提供Internet訪問的網址,其中縮略圖數據託管。)

getThumbnail(path:format:size:overwrite:destination:)方法是下載風格的請求,所以你應該使用它"Download-style request" in the readme下如圖所示,按「下載到URL「示例。

getThumbnail(path:format:size:)方法將返回內存中的縮略圖數據。根據"Download-style request" in the readme,按照「下載到數據」示例,您可以使用它。

在任何一種情況下,請注意您收到的path/not_found錯誤是指您提供的path: filename參數。也就是說,Dropbox帳戶中沒有找到該路徑。您應該指定您想要縮略圖的文件的遠程Dropbox路徑。

+0

您是否有關於使用API​​ v2 swift sdk的示例代碼?我對此非常空白。 – user3804063

+1

你可以參考一個[示例應用程序](https://github.com/dropbox/PhotoWatch),但看起來你已經設法根據[你的新帖子](https:/ /)編寫'getTemporaryLink'調用。 /stackoverflow.com/questions/43890727/ios-collectionview-images-disappear-on-scrolling-and-sometimes-overlaps)。 – Greg

+0

非常感謝,非常感謝。我可以下載尺寸爲32 * 32和任何尺寸的縮略圖。 非常感謝你的寶貴時間。 但我有一個問題,我收集查看細胞圖像滾動消失。 http://stackoverflow.com/questions/43890727/ios-collectionview-images-disappear-on-scrolling-and-sometimes-overlaps/43891043?noredirect=1#comment74818329_43891043 – user3804063