From: Radek Czajka Date: Thu, 24 Nov 2022 10:51:13 +0000 (+0100) Subject: Fix photo upload from wikidata. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/cea1338141dcef9834201621c6a2b2cd9ee6b546 Fix photo upload from wikidata. --- diff --git a/src/catalogue/static/catalogue/wikidata_admin.js b/src/catalogue/static/catalogue/wikidata_admin.js index d2af5f70..a9af9c91 100644 --- a/src/catalogue/static/catalogue/wikidata_admin.js +++ b/src/catalogue/static/catalogue/wikidata_admin.js @@ -112,16 +112,18 @@ function set_file_from_url($input, url, callback) { filename = decodeURIComponent(url.match(/.*\/(.*)/)[1]); - $.ajax({ - url: url, - success: function(content) { - let file = new File([content], filename); - let container = new DataTransfer(); - container.items.add(file); - $input[0].files = container.files; - callback() - } - }); + + let req = new XMLHttpRequest(); + req.open("GET", url, true); + req.responseType = "arraybuffer"; + req.onload = (event) => { + let file = new File([req.response], filename); + let container = new DataTransfer(); + container.items.add(file); + $input[0].files = container.files; + callback(); + }; + req.send(null); } }); })(jQuery);