无法在服务器上上传录制的视频和捕获的图像

时间:2017-05-12 09:38:48

标签: ios swift alamofire

我正在尝试在服务器上传视频但是由于我在参数中的路径不正确,它会让我失败。         Api命中成功但在响应之后fail.code是: -

    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**.*/

0 个答案:

没有答案