Can't Open Any HTTPS Resource Swift

隐身守侯 提交于 2019-12-11 15:39:29

问题


So I'm developing an app that will need to present both PDF and PPTX files served via the HTTPS protocol. However, try as I might I can't get it to work. At first I used PDFKit, and I did the following:

URLSession.shared.dataTask(with: url!) { (data, resp, err) in 

    // viewer is a PDFView instance bound to the VC

    self.viewer.document = PDFDocument(data: data!) 

}.resume()

Nothing came up in the view. I looked down at the console and saw the following error message:

failed to find PDF header: `%PDF' not found.

I then figured PDFKit was a waste of time considering the fact that I wanted to load PowerPoint files as well so I went with QuickLook. The implementation of that just follows the documentation, simply returning a URL as a QLPreviewItem and setting the proper deletate and data source. Just as with PDFKit, it worked fine for HTTP files but not for HTTPS. Any ideas of how to circumvent this?

来源:https://stackoverflow.com/questions/51619778/cant-open-any-https-resource-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!