When I record video on iPhone, I would like to press use video button to upload video and post other parameters to server using Alamofire in iOS Swift. How I can do it?
Asked
Active
Viewed 4,447 times
1
-
1Possible duplicate of [Send POST parameters with MultipartFormData using Alamofire, in iOS Swift](http://stackoverflow.com/questions/31949118/send-post-parameters-with-multipartformdata-using-alamofire-in-ios-swift) – tonik12 Oct 05 '16 at 13:11
-
1Have you tried it? did you work on some code. – Hamza Ansari Oct 05 '16 at 13:11
1 Answers
0
try this
Alamofire.upload(.POST, API_URL, multipartFormData: { (formData:MultipartFormData) in
formData.appendBodyPart(fileURL: NSURL(fileURLWithPath: filePath), name: name)
}, encodingCompletion: { encodingResult in
switch encodingResult {
case .Success(let upload, _, _):
upload.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
print(totalBytesRead)
}
upload.responseJSON { response in
debugPrint(response)
//uploaded
}
case .Failure(let encodingError):
//Something went wrong!
if DEBUG_MODE {
print(encodingError)
}
}
})

rv7284
- 1,092
- 9
- 25