无法打开文件“IMG_00001.MOV”,因为您无权查看该文件

时间:2017-06-27 10:12:02

标签: ios swift3

尝试将视频网址转换为数据然后收到错误:

"The file “IMG_00001.MOV” couldn’t be opened because you don’t have permission to view it."

这是我的代码:

let videoUrl = Dictionary.object(forKey: "videoUrl") as! String

do {
    let vidUrl = URL(fileURLWithPath: videoUrl)

    let videoData = try Data.init(contentsOf: vidUrl)
    videoMainData = videoData.base64EncodedString(options: Data.Base64EncodingOptions.endLineWithLineFeed)
} catch let error as NSError {
    print(error.localizedDescription)
}

1 个答案:

答案 0 :(得分:0)

videoMainData?.write(to: vidUrl

尝试添加此行后..                                   videoMainData = videoData.base64EncodedString(options: Data.Base64EncodingOptions.endLineWithLineFeed)