首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SwiftyDropbox上传图片到Dropbox

使用SwiftyDropbox上传图片到Dropbox
EN

Stack Overflow用户
提问于 2016-11-07 14:23:04
回答 1查看 975关注 0票数 1

我正在尝试使用SwiftyDropbox和Swift 3.0将UIImageView中的图像上传到Dropbox。当我按下这个按钮时,在第一个print语句之后没有任何反应。我做错了什么。

代码语言:javascript
复制
 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)
})
}


}
EN

回答 1

Stack Overflow用户

发布于 2017-07-11 00:57:52

如果您的客户端为空,则您未登录。请尝试登录并再次登录。否则,它应该工作得很好。

https://dropbox.github.io/SwiftyDropbox/api-docs/latest/index.html#configure-your-project

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40458974

复制
相关文章

相似问题

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