没有权限在swift中访问视频文件路径

时间:2016-09-20 12:12:28

标签: ios iphone swift

将文件上传到服务器时出现此错误

Error Domain=NSCocoaErrorDomain Code=257 "The file “IMG_0011.MOV”   couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/var/mobile/Media/DCIM/100APPLE/IMG_0011.MOV, NSUnderlyingError=0x13b157510 {Error Domain=NSPOSIXErrorDomain Code=1  "Operation not permitted"}}

我将路径转换为NSDATA的代码是:

 let videoURL = User.sharedInstance.arrRoomGalleryVideos.objectAtIndex(index) as? NSURL
            var movieData: NSData?
            do {
                let video = try NSData(contentsOfURL: videoURL!, options: .DataReadingMappedIfSafe)
               // print("video", video)
                multipartFormData.appendBodyPart(data: video, name: "video_path[]", fileName: strVidName, mimeType: "mp4/.mov")
            } catch {
                print(error)
                return
            }

1 个答案:

答案 0 :(得分:0)

你可以试试这个 -

导航至Build Settings - >转到“构建选项”并将"Compiler for C/C++/Objective-C"的值更改为Default Compiler.

有关更多解决方案,请查看this