The file "xxx.mp4" could not be opened because you do not have permission to view

I use the Alamofire multipartFormData.append(URL, withName: "file") method to upload the video to the server, but I have an error message:

multipartEncodingFailed (Alamofire.AFError.MultipartEncodingFailureReason.bodyPartFileNotReachableWithError (file: ///var/mobile/Media/DCIM/100APPLE/IMG_0939.mp4, Error Domain = NSCocoaErrorDomain IMG_04 because it failed to open code = 257.0939) you do not have permission to view it. "UserInfo = {NSURL = file: ///var/mobile/Media/DCIM/100APPLE/IMG_0939.mp4, NSFilePath = / var / mobile / Media / DCIM / 100APPLE / IMG_0939.mp4, NSUnderlyingError = 0x174450d10 {Domain error = NSPOSIXErrorDomain Code = 1 "Operation not allowed"}}))

I discovered that Privacy - Photo Library is a description of the use, but I got this error, and I do not know.

My code is:

 alamofireManager?.upload( multipartFormData: { multipartFormData in for i in 0..<videoURLs.count { multipartFormData.append(videoURLs[i], withName: "file") } }, to: url + urlString, headers: headers, encodingCompletion: { encodingResult in switch encodingResult { case .success(let upload, _, _): upload.uploadProgress(closure: { (progress) in //Print progress //print(progress) }) upload.responseJSON { response in if let value = response.result.value as? [String: AnyObject]{ success(value) } } case .failure(let encodingError): failture(encodingError) } } ) 
+5
source share

Source: https://habr.com/ru/post/1266148/


All Articles