首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能使用SwiftyDropbox调用“上传”

不能使用SwiftyDropbox调用“上传”
EN

Stack Overflow用户
提问于 2017-10-14 03:05:06
回答 1查看 420关注 0票数 0

我刚刚开始iOS开发,我正在SwiftyDropbox中使用Dropbox。我试图将一个文本文件上传到dropbox,但是我得到了以下错误:

不能使用类型为“(path:String)”的参数列表调用“upload”

这是我的密码。我做错了什么?

代码语言:javascript
复制
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    if let authResult = DropboxClientsManager.handleRedirectURL(url) {
        switch authResult {
        case .success:
            print("Logged into Dropbox successfully.")
        case .cancel:
            print("Authorization canceled.")
        case .error(_, let description):
            print("Error: \(description)")


        }

        let client = DropboxClientsManager.authorizedClient

        client.files.upload(path: "/hello.txt").response { response, error in
            if let metadata = response {
                println("Uploaded file name: \(metadata.name)")
                println("Uploaded file revision: \(metadata.rev)")

        let client = DropboxClientsManager.authorizedClient
        client?.files.createFolderV2(path: "/Auction_Upload").response { response, error in
            if let response = response {
                print(response)
            } else if let error = error {
                print(error)
            }
        }
    }
    return true
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-14 03:18:33

你不能用你已经做过的方式去做。在path文件中,您需要将路径添加到要添加文件的位置。然后你需要传递内容。这样做反而是:

代码语言:javascript
复制
let client = DropboxClientsManager.authorizedClient
let fileData = "Some test text to upload".data(using: String.Encoding.utf8, allowLossyConversion: false)!

let request = client?.files.upload(path: "/test/path/in/Dropbox/account", input: fileData)
    .response { response, error in
        if let response = response {
            print(response)
        } else if let error = error {
            print(error)
        }
    }
    .progress { progressData in
        print(progressData)
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46740450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档