I am trying to save an image on the Parse server launched with AWS. when I push the postImage button i see the following error message:
"The data couldn't be read because it isn't in the right format"
. My Xcode
version is 10.2.1
If I save the data without the image file is working, the class is created on the parse server and both the comment and the user objectIds are added.
This is the code in the button:
@IBOutlet weak var comment: UITextField!
@IBOutlet weak var imageToPost: UIImageView!
@IBAction func postImage(_ sender: Any) {
if let image = imageToPost.image {
// Create the class object for the Post
let post = PFObject(className: "Post")
post["Message"] = comment.text
post["userId"] = PFUser.current()?.objectId
// Create the image data
if let imageData = image.pngData() {
let imageFile = PFFileObject(name: "image.png", data: imageData)
post["imageFile"] = imageFile
post.saveInBackground { (success, error) in
if let error = error {
print("There were issues saving the file: \(error.localizedDescription)")
self.displayAlert(title: "Error", message: "Image could not be posted, please try again later")
} else {
// SAving successful
print("File saved correctly")
self.displayAlert(title: "Image Posted", message: "Your image hase posted successfully")
self.comment.text = ""
self.imageToPost.image = nil
}
}
}
}
}
So I would expect that the class is created with the comment, userId and the image file. But the class is not even created as it goes directly in the error management