How can I upload an Image to Firebase with different strings?

Viewed 24

In this code Im able to successfully post an image to Firebase. But I would like to add some strings along with it.

   @objc func Post(){

        print("Post Clicked")
        let imageName = "\(NSUUID().uuidString).jpeg"
        let imagesFolder = Storage.storage().reference().child("Post")

        if let image = imageView.image{
            if let imageData : Data = image.jpegData(compressionQuality: 1){
                imagesFolder.child(imageName).putData(imageData, metadata: nil) { (metaData, error) in
                    if let error = error{
                        print(error)
                    }else{
                        imagesFolder.child(imageName).downloadURL { (url, error) in
                            if let imageURL = url?.absoluteString{
                                self.imageURL = imageURL
                                print("Success")

                            }
                        }
                    }
                }
            }
        }

    }

How can I upload these custom strings from UILabels along with the same image? I have tried placing this code in different areas of the Post function but it does not work. What is the proper way to do this?

//([
//"Title"      : titleLabel.text,
//"Article"    : articleLabel.text,
//"Author"     : authorLabel.text,
//"Date"       : DateLabel.text,
//])

0 Answers
Related