【发布时间】:2018-05-30 19:46:29
【问题描述】:
Error Domain=NSCocoaErrorDomain Code=257 "无法打开文件“IMG_9807.MOV”,因为您没有查看权限。" UserInfo={NSFilePath=/var/mobile/Media/DCIM/109APPLE/IMG_9807.MOV, NSUnderlyingError=0x1c1e5fe00 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not allowed"
我正在向其他控制器发送资产 URL 并尝试转换为数据
PHImageManager.default().requestAVAsset(forVideo: self.albumView.phAsset, options: options) { (video, audioMix, info) in
DispatchQueue.main.async {
let urlAsset = video as! AVURLAsset
self.dismiss(animated: false, completion: {
self.delegate?.fusumaVideoCompleted(withFileURL: urlAsset.url)
})
}
}
下面是将 AVAssetUrl 转换为数据的方法
do {
let data = try Data(contentsOf: product.videoURL, options: .mappedIfSafe)
return .upload(.multipart([MultipartFormData(provider: .data(data), name: "post[video]", fileName: "video.\(pathExtension)", mimeType: "video/\(pathExtension)")]))
} catch {
debugPrint(error)
}
【问题讨论】:
-
可能是stackoverflow.com/questions/35652094/… 的复制品,它告诉你你需要知道的一切。