繁体   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