I'm very new in iOS development. So I'm trying to download pdf or image from firebase storage with URL using Alamofire and then I want to display with quicklook. I tried this example but no luck. Present preview of downloaded file directly in app
import UIKit
import Alamofire
import QuickLook
class DocumentViewer: UIViewController{
var previewItem = URL?.self
var refrenceDocURL: URL? // here i get the url from another view controller but never use it because I don't know where should I use it.
func downloadFile(fileUrl: URL) {
let destination: DownloadRequest.DownloadFileDestination = { _, _ in //ERROR: 'DownloadFileDestination' is not a member type of class 'Alamofire.DownloadRequest'
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let fileURL = documentsURL.appendingPathComponent(documentFilename)
return (fileURL, [.removePreviousFile])
}
Alamofire.download(fileUrl, to: destination) //ERROR: Module 'Alamofire' has no member named 'download'
.response(completionHandler: { (downloadResponse) in
let previewController = QLPreviewController()
previewController.dataSource = self
self.previewItem = downloadResponse.destinationURL
self.present(previewController, animated: true, completion: nil)
})
}
}
extension DocumentViewer: QLPreviewControllerDataSource {
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return 1
}
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
return self.previewItem as! QLPreviewItem
}
}