so my doubt is on how to upload an image using Alamofire, from what researched people uses the solutions here https://github.com/Alamofire/Alamofire/issues/110. However my curl request should look like this:
curl -X POST "api.local.app.com:9000/1/media/upload" -F “picture=@filename.png” -H “Authorization: Alpha ahudhasiadoaidjiajdiudaiusdhuiahdu” -v
I'm trying to do that this way:
Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders = ["Authorization" : "Alpha \(userToken)" ]
var fileManager = NSFileManager()
var tmpDir = NSTemporaryDirectory()
let filename = "tempPicture.png"
let path = tmpDir.stringByAppendingPathComponent(filename)
var error: NSError?
let imageData = UIImagePNGRepresentation(image)
fileManager.removeItemAtPath(path, error: nil)
println(NSURL(fileURLWithPath: path))
if(imageData.writeToFile(path,atomically: true)){
println("Image saved")
}else{
println("Image not saved")
}
Alamofire.upload(.POST, databaseURL + "/media/upload", NSURL(fileURLWithPath: path)!).progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in
println( String(totalBytesWritten) + "/" + String(totalBytesExpectedToWrite))
}
.responseJSON { (request, response, data, error) in
From what I understand this should work however the Alamo returns
Error: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 2.) UserInfo=0x7e16d9e0 {NSDebugDescription=Invalid value around character 2.}).