WKWebView - Download data from blob:https:// URL

Hi,

I need to download data as a file from blob: URL. My macOS app uses WKWebView control and hosts web page. This web page provides a link to export the contents of the page as a CSV file.

webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) 

The above function returns blob: url. But I don't know how to convert/save blob: URL contents into a file.

Is it possible to download contents using blob: URL? If so how do I download it?
You may want to figure out why you are getting a blob: URL from the webpage. This StackOverflow article explains more about what a blob: URL is and what it is used for: https://stackoverflow.com/questions/30864573/what-is-a-blob-url-and-why-it-is-used

One option may be to convert the blob: URL to a data: URL and then try to load the data: URL so it gets sent to the WKWebView delegate method instead of the blob: URL.

This (unfixed) issue may also be related:

WKWebView does not support blob: URLs as href value in anchors with download attribute
https://bugs.webkit.org/show_bug.cgi?id=216918

WKWebView - Download data from blob:https:// URL
 
 
Q