[英]Can't invoke “upload” using SwiftyDropbox
我刚刚开始iOS开发,并且将Dropbox API与SwiftyDropbox结合使用。 我正在尝试将文本文件上传到保管箱,但出现以下错误:
无法使用类型为“(路径:字符串)”的参数列表调用“上传”
这是我的代码。 我究竟做错了什么?
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
}
您无法像以前那样去做。 在提交的path
您需要将路径添加到要添加文件的位置。 然后,您需要传递内容。 改为这样做:
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)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.