title: Download many files (photos, videos) in background with priority order
body: <p>At first start of app I want to download all files from server and I want to continue in downloading even when user leaves app (it's not in foreground). The files I need to download are thumbnails, photos in original size, other files and video. I want to download them in order as I wrote before. </p>
  
  <p>I am using Alamofire and I set session manager:</p>
  
  <pre><code>let backgroundManager: Alamofire.SessionManager = {
      let bundleIdentifier = "com....."
      return Alamofire.SessionManager(
        configuration: URLSessionConfiguration.background(withIdentifier: bundleIdentifier + ".background")
      )
    }()
  </code></pre>
  
  <p>Then I am using it like this:</p>
  
  <pre><code>  self.backgroundManager.download(fileUrl, to: destination)
      .downloadProgress { progress in
        //print("Download Progress: \(progress.fractionCompleted)")
      }
      .response(completionHandler: result)
  </code></pre>
  
  <p>It's in downloadPhoto method and I am calling it:</p>
  
  <pre><code>for item in items {
        self.downloadPhoto(item: item, isThumbnail: true, shouldReloadData: false, indexPath: nil)
        self.downloadPhoto(item: item, isThumbnail: false, shouldReloadData: false, indexPath: nil)
  }
  </code></pre>
  
  <p>Then I could add call for file download and video download and other. But all this requests have same priority and I would like to download thumbnails first (because that's what user see at first) then full size images and after all images are downloaded then files and videos. But all must be in queue because if user starts app and then set it to background and left it for several hours all must be downloaded. Is this possible? And how can I do this? </p>
  
  <p>I was looking at alamofire that it has component library AlamofireImage which has priority based downloading but images are just part of files which I want to prioritize. Thanks for help</p>