Ios 无法在服务器上上载录制的视频和捕获的图像
我正试图在服务器上上传视频,但由于参数中的路径不正确,它给了我失败响应。 Api命中成功,但响应失败。代码为:-Ios 无法在服务器上上载录制的视频和捕获的图像,ios,swift,alamofire,Ios,Swift,Alamofire,我正试图在服务器上上传视频,但由于参数中的路径不正确,它给了我失败响应。 Api命中成功,但响应失败。代码为:- if let pickedVideo:URL = (info[UIImagePickerControllerMediaURL] as? URL) { // Save video to the main photo album ///////////////
if let pickedVideo:URL = (info[UIImagePickerControllerMediaURL] as? URL) {
// Save video to the main photo album
///////////////
let selectorToCall = #selector(ViewController.videoWasSavedSuccessfully(_:didFinishSavingWithError:context:))
UISaveVideoAtPathToSavedPhotosAlbum(pickedVideo.relativePath, self, selectorToCall, nil)
// Save the video to the app directory so we can play it later
let videoData = try? Data(contentsOf: pickedVideo)
let paths = NSSearchPathForDirectoriesInDomains(
FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let documentsDirectory: URL = URL(fileURLWithPath: paths[0])
let dataPath = documentsDirectory.appendingPathComponent(saveFileName)
try! videoData?.write(to: dataPath, options: [])
print("Saved to " + dataPath.absoluteString)
大宗报价
大宗报价
使用静态路径尝试一次在上面的代码中,我不在任何地方使用路径,因为我不知道我必须在哪里设置路径。不像在本地/在您的应用程序中,您可以保存在任何路径中,但当您发送到服务器时,请您的后端开发人员保存路径。
Alamofire.upload(multipartFormData: { (multipartFormData) in
multipartFormData.append(videoData!, withName: "Video")
}, to:"http://vallesoft.co/imageandroid/upload.php")
{ (result) in
switch result {
case .success(let upload, _ , _):
upload.uploadProgress(closure: { (progress) in
print("uploding")
})
upload.responseJSON { response in
print("response is ", response)
print("done")
}
case .failure(let encodingError):
print("failed")
print(encodingError)
}
}
}
/* **After upload i got "done" but from server side could not upload .Due to incorrect path**.*/