我有一个问题。
当我print("Video URL: \(self.videoUrl.description)")
时,我在输出中得到了这个:
Video URL: file:///var/mobile/Containers/Data/Application/92BDA035-131C-4FD2-A176-25F77C1D295B/Documents/video.mp4
我使用它将文件上传到服务器:
func uploadVideo(){
let currentUploads = PFObject(className: "myClassOne")
currentUploads.saveInBackgroundWithBlock({ (success: Bool, error: NSError?) -> Void in
if error == nil{
//**Success saving, now save video.**//
currentUploads["userFile"] = try! PFFile(name: "video.mp4", contentsAtPath: self.videoUrl.description)
currentUploads.saveInBackgroundWithBlock({ (success: Bool, error: NSError?) -> Void in
if error == nil{
// Take user home
print("Successfully uploaded")
})
}
else{
print(error, terminator: "")
}
})
}
else{
print(error, terminator: "")
}
})
}
我收到此错误:
致命错误:'尝试!'表达式意外地引发了错误:错误 Domain = NSCocoaErrorDomain Code = 4"无法在路径上创建PFFile '文件:///var/mobile/Containers/Data/Application/92BDA035-131C-4FD2-A176-25F77C1D295B/Documents/video.mp4' ;: 文件不存在。" UserInfo = {NSLocalizedDescription =失败 在路径上创建PFFile '文件:///var/mobile/Containers/Data/Application/92BDA035-131C-4FD2-A176-25F77C1D295B/Documents/video.mp4' ;: 文件不存在。}:file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-703.0.18.1/src/swift/stdlib/public/core/ErrorType.swift, 第54行
有什么问题?当我从println
成功获取网址时,为什么会出现“文件不存在”?有什么想法/建议吗?