func uploadProfilePicture(data : NSData,completion: (success : Bool) -> Void) {
PKHUD.sharedHUD.contentView = PKHUDTextView(text: "Loading...")
PKHUD.sharedHUD.show()
Alamofire.upload(.POST,GlobalConstants.KUpdateProPic,multipartFormData:
{
multipartFormData in
multipartFormData.appendBodyPart(data : data, name: "image", fileName: Helper.timeStamp(), mimeType: "image/png")
},
encodingCompletion: { encodingResult in
switch encodingResult {
case .Success(let upload, _, _):
upload.responseJSON { response in
debugPrint(response)
let status : NSString = response.result.value?.valueForKey("status") as! String
if(status .isEqualToString("1")){
let profile_image : NSString = response.result.value?.valueForKey("profile_image") as! String
defaults.setObject(profile_image, forKey:"imageURL")
let fileUrl = NSURL(string: profile_image as String)
MyViewState.profile_image = (fileUrl?.lastPathComponent)!
PKHUD.sharedHUD.hide()
completion (success: true)
}else{
PKHUD.sharedHUD.hide()
completion(success : false)
}
}
case .Failure(let encodingError):
print(encodingError)
PKHUD.sharedHUD.hide()
completion(success : false)
} })
}
Above is my code to upload image. Now, I want to send some other parameters with this upload and I want to know how many bytes are written.
I have tried to use the links below but I haven't been able to achieve this. Uploading file with parameters using Alamofire