我遇到問題。NSURL錯誤 - 文件不存在
當我做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: "")
}
})
}
我得到這個錯誤:
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=4 "Failed to create PFFile at path 'file:///var/mobile/Containers/Data/Application/92BDA035-131C-4FD2-A176-25F77C1D295B/Documents/video.mp4': file does not exist." UserInfo={NSLocalizedDescription=Failed to create PFFile at path 'file:///var/mobile/Containers/Data/Application/92BDA035-131C-4FD2-A176-25F77C1D295B/Documents/video.mp4': file does not exist.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-703.0.18.1/src/swift/stdlib/public/core/ErrorType.swift, line 54
有什麼不對?爲什麼我在成功獲取println
的網址時得到「文件不存在」?任何想法/建議?
嘗試'LS的/ var /移動/集裝箱/數據/應用/ 92BDA035-131C-4FD2-A176-25F77C1D295B /文檔/ video.mp4' – Jeef
它的工作原理上模擬器? – Jeef
@Jeef不工作的第一個鏈接,我不能在模擬器,因爲我使用手機相機拍攝視頻和上傳。 –