【发布时间】:2017-10-24 02:35:57
【问题描述】:
我正在尝试获取打印的项目并将其与其他网点一起插入到我的 Firebase 数据库中。谢谢!
@objc(imagePickerController:didFinishPickingMediaWithInfo:) func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
{
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
myImageView.image = image
} else {
//error
}
self.dismiss(animated: true, completion: nil)
let storageRef = FIRStorage.storage().reference().child("myImage.png")
if let uploadData = UIImagePNGRepresentation(self.myImageView.image!) {
storageRef.put(uploadData, metadata: nil, completion:
{
(metadata, error) in
if error != nil {
print("error")
return
} else {
print((metadata?.downloadURL()?.absoluteString)!)
//i want to take the line above and insert it into the database
}
})
}
}
@IBAction func addPost(_ sender: Any) {
if self.titleText.text != "" && self.authorText.text != "" && self.mainText.text != "" && self.dateText.text != "" {
ref?.child("Posts").childByAutoId()
.setValue(["Title": titleText.text,
"Article": mainText.text,
"Author": authorText.text,
"Date": dateText.text ])
//insert the download URL above
self.performSegue(withIdentifier: "kost", sender: self)
}
}
【问题讨论】:
-
我的回答有帮助吗,也许对您的问题的进一步解释会有所帮助
-
在这里回答了您的问题。 stackoverflow.com/a/44061967/5878081
-
你能具体解释一下什么不起作用吗?可能有一些编码错误; storageRef.put(uploadData, metadata: nil, completion: 应该是 storageRef.putData(uploadData, metadata: nil) { (metadata, error) in。见@ 987654323@了解详情。
标签: ios swift firebase firebase-realtime-database