         }
         
         do {
-            let url = try writeToCache(image: image, request: request)
+            let url = try writeToCache(image: image, kind: request.kind)
             request.handler(url)
         } catch {
             request.handler(nil)

    enum Error: Swift.Error {
        case jpegCompressionFailed
        case diskWriteFailed
    }
}

        }
        
        return imagePicker
    }
    
    public func createVideoThumbnail(forURL videoURL: URL) -> Task<URL> {
        let deferred = Deferred<Task<URL>.Result>()

        let asset = AVAsset(url: videoURL)
        let durationSeconds = CMTimeGetSeconds(asset.duration)
        let generator = AVAssetImageGenerator(asset: asset)
        generator.appliesPreferredTrackTransform = true
        
        let time = CMTimeMakeWithSeconds(durationSeconds/3.0, preferredTimescale: 600)
        generator.generateCGImagesAsynchronously(forTimes: [NSValue(time: time)]) { (_, thumbnail, _, _, _) in
            guard let thumbnail = thumbnail else {
                return
            }
            let image = UIImage(cgImage: thumbnail)
            do {
                let finalURL = try self.writeToCache(image: image, kind: .photo)
                deferred.fill(with: .success(finalURL))
            } catch let error {
                deferred.fill(with: .failure(error))
            }
        }
        
        return Task(deferred)
    }
    
    // MARK: UIImagePickerControllerDelegate
