I'm trying to send an image to my API using alamofire
and SwiftyJSON
. I've been trying some different ways to do that, however no success so far. The last one I tried is the base64EncodedString
and is not working. I have the variable styleStrength as a JSON.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]){
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
self.profileImage.image = image
self.profileImage.isHidden = false
self.profileImage.contentMode = UIViewContentMode.scaleAspectFill
let imageData = UIImagePNGRepresentation(image)
let base64String = imageData!.base64EncodedString(options: [])
var styleStrengthData = JobSeekerBuildProfile.loadJobSeekerBuildProfile()
styleStrengthData["Personal_Style"]["profile_pic_file"].stringValue = base64String + ".jpg"
JobSeekerBuildProfile.storeJobSeekerBuildProfile(j: styleStrengthData)
}else{
//error message
}
self.dismiss(animated: true, completion: nil)
}
As return I have a really huge image name but the API doesn't update.