Dom Exception 18 when trying to use imgSrcToBlob on an image loaded from a file:// url in WKWebView
racekarl opened this issue · 2 comments
In my Cordova app I am testing WKWebView, which implements much stricter CORS checks than UIWebView.
I capture a photo from the Cordova camera plugin (which outputs a file:// uri) then load that into an Image object, if I then pass that image object to blobUtil.imgSrcToBlob I get a DOM Exception 18.
This all works correctly using UIWebView.
I guess this is because the file system does not attach CORS headers and so the blobUtil cannot call canvas.toDataURL
Yeah, you can't do this unless CORS is enabled on the remote server. It's a security issue.
The solution is to enable CORS on the remote server. Sorry about that!
Ooh or actually in this case, you can start a local fileserver and then use that instead of file://
. Last I checked, this is how Cordova is getting around security issues with WKWebView (which is pretty broken when it comes to loading local file://
URLs).