【发布时间】:2019-01-10 09:42:12
【问题描述】:
我的应用程序有文件下载选项,它使用 alamofire 下载方法下载文件。下载完成后,我需要呈现文件的预览而不将其保存到内部/云存储中。我怎样才能实现这个类似whatsapp的功能,在下载文件后显示预览。
func downloadFile(fileUrl: URL) {
let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)
Alamofire.download(fileUrl, to: destination)
.response(completionHandler: { (downloadResponse) in
self.dic.url = downloadResponse.destinationURL
self.dic.uti = downloadResponse.destinationURL!.uti
let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
self.dic.presentOpenInMenu(from: rect, in: self.view, animated: true)
})
}
【问题讨论】:
-
alamofire.download 已经下载了一个文件并将其保存到您传递给它的目标位置,该目标位于应用程序目录的内部存储中
-
因为我发帖后才得到解决方案,所以alamofire的参考就在那里。您可以直接将您的文件位置分配给
self.previewItem作为参考。
标签: ios swift quicklook document-preview