将图像上传到Parse失败

时间:2017-10-18 22:30:52

标签: swift parse-platform uiimagepickercontroller

我无法保存捕获的图像并使用Parse将其发送到我的mongodb。我不确定我的错误是什么。我绝对使用我的imagePickerController确保图像捕获部分正确。

这是我的代码:

do.call(rbind.data.frame, c(goodresultsdf, stringsAsFactors = FALSE))
#   geometry.id geometry.place_id geometry.location.lat geometry.location.lon
# 1         foo              quux              25.66544             -100.4354
# 2         foo              quux              25.66544             -100.4354

这是我在控制台中的输出:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
        print("Did finish picking media. Image \(image)")


        let imageData = UIImagePNGRepresentation(image)
        let imageFile = PFFile(name:"image.png", data:imageData!)



        let pohto_object = PFObject(className: "UserPhoto")
        pohto_object["imageName"]  = "My trip to Hawaii!"
        pohto_object["imageFile"] = imageFile

        pohto_object.saveInBackground() { (success, error) -> Void in
            if error == nil {
                print("Saved in server")
            } else {
                print("did not save because: \(error!)")
            }
        }
        print ("the object is \(pohto_object)")




    } else {
        print("Did finish picking media. Image is nil")
    }
    dismiss(animated: true)
}

1 个答案:

答案 0 :(得分:0)

所以我的问题是通过从Leo指示的UIImagePNGRepresentation更改为UIImageJPEGRepresentation来解决的。