簡體   English   中英

iOS Dropbox錯誤加載縮略圖

[英]iOS Dropbox error loading thumbnails

我想獲得我在視圖上顯示的dropbox文件的縮略圖。 我知道我要使用loadThumbnail方法,但我不知道如何做到這一點。

我寫了這個:

for file in dropboxMetadata.contents {
        dbRestClient.loadThumbnail(file.path, ofSize: "s", intoPath: "https://api-content.dropbox.com/1/thumbnails/auto/")
}

但我得到一些像這樣的錯誤:

error making request to /1/thumbnails/dropbox/star.jpg - (4) Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed.

謝謝你的幫助 !

Petesh有正確的想法。 intoPath是這些縮略圖的目標目錄。

嘗試這個:

    func createTempDirectory() -> String? {
    let tempDirectoryTemplate = NSTemporaryDirectory().stringByAppendingPathComponent("XXXXX")

    let fileManager = NSFileManager.defaultManager()

    var err: NSErrorPointer = nil

    // remove any previous temporary folder that's there, in case it's there
    fileManager.removeItemAtPath(tempDirectoryTemplate)

    if fileManager.createDirectoryAtPath(tempDirectoryTemplate, withIntermediateDirectories: true, attributes: nil, error: err) {
        return tempDirectoryTemplate
    } else {
        print("can't create temporary directory at \(tempDirectoryTemplate)")
        return nil
    }
}

在這個問題中找到的上述代碼

然后你可以改變你自己的代碼來做類似的事情:

let temporaryDirectory = createTempDirectory()
for file in dropboxMetadata.contents {
        dbRestClient.loadThumbnail(file.path, ofSize: "s", intoPath: temporaryDirectory)
}

如果這樣做,那么您可以將“ intoPath ”參數更改為您認為更合適的任何目錄。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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