1

Without a swift library for cloudinary, I'm trying to upload photos using Alamofire instead.

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {

    let newphoto = info[UIImagePickerControllerOriginalImage] as? UIImage

    let parameters : [String :  AnyObject] = [
        "file" : newphoto!,
        "folder" : "production/photos",
        "upload_preset" : "not-cropped",
        "tags" : "object,daily-photo,operator_\(operatorId),child_\(childId),\(givenName)-\(familyName),production,25-Feb-2016,Feb-2016"
    ]

    Alamofire.request(.POST, "https://api.cloudinary.com/v1_1/<<ID>>/image/upload", parameters: parameters)
        .responseJSON { (response) -> Void in
            if let value = response.result.value {
                let json = JSON(value)
                print("Request \(response.request)")
                print("json is \(json)")
            }
    }

This runs and compiles ok, but I get the following error.

json is {
  "error" : {
      "message" : "Unsupported source URL: <UIImage: 0x140053200> size {2448, 3264} orientation 3 scale 1.000000"
  }
}

Is this fixable or is it not possible to upload to cloudinary using Alamofire?

Craig.Pearce
  • 746
  • 7
  • 25

0 Answers0