I must add a video to server utilizing Alamofire. The consumer selects the video from machine and I get URL in didFinishPickingMediaWithInfo
efficiently as follows:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo data: [UIImagePickerController.InfoKey : Any]) {
let ivHandler = LocalImageVideoHandler()
let videoUrl = data[UIImagePickerController.InfoKey.mediaURL] as? NSURL?
let pathString = videoUrl??.filePathURL
self.dismiss(animated: true)
}
After which I add the video utilizing the next code:
func uploadPostFiles(imageVideoPath:String,parameters:Parameters) {
AF.add(multipartFormData: { multipartFormData in
// Chosen Video Path/URL = "file:///non-public/var/cell/Containers/Information/PluginKitPlugin/51D56143-9303-407D-8E37-AAC576766407/tmp/trim.59847342-DD95-4B74-A7BE-82BA0F3D706E.mp4"
multipartFormData.append(URL(string: imageVideoPath )!, withName: "file", fileName: "trim.59847342-DD95-4B74-A7BE-82BA0F3D706E.mp4",mimeType: "video/mp4")
for (key, worth) in parameters {
if let temp = worth as? String {
multipartFormData.append(temp.knowledge(utilizing: .utf8)!, withName: key)
}
}
}, to: ApiConstant.BASE_URL+"/add", technique: .publish, headers: getHeaders().self)
.validate(statusCode: 200..<500)
.response { response in
if response.knowledge != nil&&response.response?.statusCode==200 {
do {
let customers = strive JSONDecoder().decode(GetPostModel.self
, from: response.knowledge!)
debugPrint(customers)
if(customers.standing){
}else{
}
} catch let error as NSError {
}
}else{
}
}
It enters within the failure block, and the next error shows:
The URL supplied is a listing:
file:///non-public/var/cell/Containers/Information/PluginKitPlugin/51D56143-9303-407D-8E37-AAC576766407/tmp/trim.3751F517-4A5D-43C3-B8ED-BC41313653FE.mp4