title: iOS Photo Library read access
body: <p>After the user gave us permission to access his Camera Roll. We would like to grab the data and upload it to our services from inside our app.
  Is there a way to access the video data from the file? The only way to open the video file is to create an AVAsset. But that's not enough for me.</p>
  
  <p>I'm aware off</p>
  
  <pre><code>func requestExportSessionForVideo(_ asset: PHAsset!,
                        options options: PHVideoRequestOptions!,
                   exportPreset exportPreset: String!,
                  resultHandler resultHandler: ((AVAssetExportSession!,
                      [NSObject : AnyObject]!) -&gt; Void)!) -&gt; PHImageRequestID
  </code></pre>
  
  <p>But in my case I just want to upload the video to our service I don't want to do:</p>
  
  <ol>
  <li>first copy the video by doing an export into my local app data</li>
  <li>and then send that data up to our service.</li>
  <li>delete the data.</li>
  </ol>
  
  <p>This approach above uses a lot of extra space and time and users with full 16GB iPhones it doesn't work well.</p>
  
  <p>Ok this is what I tried so far using the URL</p>
  
  <pre><code>var anAcces = sourceURL?.startAccessingSecurityScopedResource
  
  if !NSFileManager.defaultManager().fileExistsAtPath(sourceURL!.path!) {
      NSLog("not exist")
  }
  
  var aFileCoordinator = NSFileCoordinator(filePresenter:nil)
  var anError: NSError?
  
  aFileCoordinator.coordinateReadingItemAtURL(sourceURL!, options:.ForUploading, error:&amp;anError, byAccessor:  { (newURL: NSURL!) -&gt; Void in
      var data = NSData(contentsOfURL: newURL)
      })
  if let unError = anError {
      NSLog("Error \(unError)")
  }
  
  sourceURL?.stopAccessingSecurityScopedResource
  </code></pre>
  
  <p>This logs the following:</p>
  
  <pre><code>2015-02-08 16:20:01.947 Cameo[15706:2288691] not exist
  2015-02-08 16:20:01.991 Cameo[15706:2288691] Error Error Domain=NSCocoaErrorDomain Code=257 "The operation couldn’t be completed. (Cocoa error 257.)" UserInfo=0x170876480 {NSURL=file:///var/mobile/Media/DCIM/100APPLE/IMG_0155.MOV, NSFilePath=/var/mobile/Media/DCIM/100APPLE/IMG_0155.MOV, NSUnderlyingError=0x17005a9a0 "The operation couldn’t be completed. Operation not permitted"}
  </code></pre>