Javascript createObjectURL not working in Android browser

Why I can’t upload files created using createObjectUrl in a web view Android application. This is also not possible with the default browser (Samsung Galaxy S6 Edge). I get the message (in Swedish) "Endast http-eller https-URL: er kan hämtas.", Translation: only http or https URLs can be received.

HTML

<textarea id="editor">Hello, world!</textarea>
<a download="myFile.txt" id="fileSaver">Save as...</a>

Javascript

function updateLink() {
var editor = document.getElementById('editor'),
    fileSaver = document.getElementById('fileSaver'),
    blob = new Blob([editor.value], {
        type: 'text/plain'
    });
fileSaver.href = (window.URL || window.webkitURL).createObjectURL(blob);
}
updateLink();
fileSaver.onclick = fileSaver.oncontextmenu = updateLink;

JSFiddle: http://jsfiddle.net/no3cLwpv/1/

+4
source share

Source: https://habr.com/ru/post/1614199/


All Articles