AVCapture でキャプチャしたビデオがあり、Swift を使用して AFNetworking でアップロードしようとしています。
コード:
let manager = AFHTTPRequestOperationManager()
let url = "http://localhost/test/upload.php"
var fileURL = NSURL.fileURLWithPath(string: ViewControllerVideoPath)
var params = [
"familyId":locationd,
"contentBody" : "Some body content for the test application",
"name" : "the name/title",
"typeOfContent":"photo"
]
manager.POST( url, parameters: params,
constructingBodyWithBlock: { (data: AFMultipartFormData!) in
println("")
var res = data.appendPartWithFileURL(fileURL, name: "fileToUpload", error: nil)
println("was file added properly to the body? \(res)")
},
success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
println("Yes thies was a success")
},
failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in
println("We got an error here.. \(error.localizedDescription)")
})
上記のコードは失敗し、取得し続けます
was file added properly to the body? false"
ViewControllerVideoPath
次のビデオの場所を含む文字列であることに注意してください。
"/private/var/mobile/Containers/Data/Application/1110EE7A-7572-4092-8045-6EEE1B62949/tmp/movie.mov"
using println()
....上記のコードは、ディレクトリに含まれるファイルをアップロードし、次を使用すると機能します。
var fileURL = NSURL.fileURLWithPath(NSBundle.mainBundle().pathForResource("test_1", ofType: "mov")!)
したがって、間違いなく私のPHPコードは問題ありません。問題は、デバイスに保存されたファイルのアップロードにあります。ここで何が間違っていますか?