For: Xcode tell downloaded data file type
Ebooks free online download | Haikuu download batch files |
Shooter games download for pc for free | Easyworship 7 license file download |
Fall out boy immortals mp3 song free download | How to download dell drivers for windows 10 |
Ps4 downloads stop | Download ssms for windows 10 |
How to download a PDF via WKWebView but open it in QuickLookPreview?
4 Replies
Hi again
With external help, I was able to fix my problem.
The solution ist now to avoid the separate download task with URLSession.shared.dataTask and hence avoid the sync problem between the WKWebView cookie storage and the shared cookie storage.
The download ist now performed with JavaScript.
I'm able to detect and intercept the request in func webView(_ webView: WKWebView, decidePolicyFor navigationAction ...).
When such a request is detected, I cancel the decision handling and call the JavaScript part with the download.
The JavaScript is executed in the WKWebView and hence I have all the authorization cookies in place and the download is successfull.
JavaScript then returns the downloaded document as binary blob which is taken over by a JavaScript message handler in Swift.
Then I just have to write the blob to a file and open the file in QuickLook preview. Works like a charm!
Here's the code in case somebody struggles with the same problem:
Does this still work for you in iOS 14?
I'm trying to implement your solution but I need to do this :
I'm not getting the Content-Disposition header here, only content-length and content-type
I sniffed the network with Wireshark and could find the HTTP answer is all ok...
Do someone have an idea where the header would be filtered out ?
Thank you so much! This helped me a lot today.
-