[英]Upload Image to Dropbox using SwiftyDropbox
I am trying to upload an image in a UIImageView to Dropbox using SwiftyDropbox and Swift 3.0. 我正在尝试使用SwiftyDropbox和Swift 3.0将UIImageView中的图像上传到Dropbox。 When I press the button nothing happens after the first print statement.
当我按下按钮后,在第一个打印语句后没有任何反应。 What am I doing wrong.
我究竟做错了什么。
import UIKit
import SwiftyDropbox
class ViewController: UIViewController {
let client = DropboxClientsManager.authorizedClient
@IBOutlet weak var myPhotoView: UIImageView!
@IBAction func logInAction(_ sender: Any) {
myButtonPressed()
}
@IBAction func sendPhotoAction(_ sender: Any) {
print("Button Pressed")
let fileData = UIImageJPEGRepresentation(myPhotoView.image!, 1.0)
//let compressedJPGImage = UIImage(data: fileData!)
let path = "/"
client?.files.upload(path: path, mode: .overwrite, autorename: true, clientModified: nil, mute: false, input: fileData!).response{ response, error in
if let _ = response { // to enable use: if let metadata = response {
print("OK")
} else {
print("Error at end")
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func myButtonPressed(){
DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: self, openURL: {(url:URL) -> Void in UIApplication.shared.openURL(url)
})
}
}
if your client is nil, then you aren't logged in. Try logging in and doing it again. 如果您的客户端为零,则表示您尚未登录。请尝试登录并再次执行此操作。 Otherwise it should work fine.
否则它应该工作正常。
https://dropbox.github.io/SwiftyDropbox/api-docs/latest/index.html#configure-your-project https://dropbox.github.io/SwiftyDropbox/api-docs/latest/index.html#configure-your-project
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.