title: Access in-app purchase on iOS device
body: <p>I am developing an iOS app that includes an in-app purchase that consists of a PNG file that is downloaded to the user's device.</p>
  
  <p>From what I can tell viewing log statements, the file is being dowloaded successfully to this directory:</p>
  
  <p><code>/var/mobile/Containers/Data/Application/ABC43D27-B79C-486C-AE39-F34BF6EF8658/Documents/</code></p>
  
  <p>How can I move the file to a location on the user's device where the user will be able to access the file, such as in the user's iCloud storage?</p>
  
  <p>In case this would be useful, below is my code for downloading the file.</p>
  
  <pre><code>func paymentQueue(queue: SKPaymentQueue, updatedDownloads downloads: [SKDownload]) {
      for download:AnyObject in downloads {
          if let down:SKDownload = download as? SKDownload {
              switch down.downloadState {
              case .Active:
                  NSLog("progress %f", down.progress)
                  NSLog("remaining %f", down.timeRemaining)
                  NSLog("Active")
                  break
              case .Cancelled:
                  NSLog("%@", "download cancelled")
                  break
              case .Failed:
                  NSLog("%@", "download failed")
                  textView.text = "Download Failed"
                  break
              case .Finished:
                  NSLog("Finished")
                  let source = down.contentURL?.relativePath
                  //var dict = NSMutableDictionary(contentsOfFile: (source! as NSString).stringByAppendingPathComponent("ContentInfo.plist"))
                  let pathToDownloadsFolder = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
                  //let pathToDownloadsFolder = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first!
                  let content:String =
                      (pathToDownloadsFolder as NSString).stringByAppendingPathComponent("bonus_brune_image.png")
                  //let content:String = pathToDownloadsFolder.URLByAppendingPathComponent("bonus_brune_image.png")
                      self.copyPathToDownloadsFolder(source!, target: content)
                      SKPaymentQueue.defaultQueue().finishTransaction(down.transaction)
                      break
              case .Paused:
                  NSLog("%@", "download paused")
                  break
              case .Waiting:
                  NSLog("%@", "download waiting")
                  break
              }
          }
      }
  }
  
  func copyPathToDownloadsFolder(source:String, target:String) {
      NSLog("Source is %@", source)
      NSLog("Target is %@", target)
  
      let filemgr:NSFileManager = NSFileManager.defaultManager()
  
      do {
      try filemgr.copyItemAtPath(source, toPath: target)
          NSLog("Success: file is now in %@", target)
      } catch let e as NSError {
          NSLog(String(e))
      }
  }
  </code></pre>