From cea1338141dcef9834201621c6a2b2cd9ee6b546 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 24 Nov 2022 11:51:13 +0100 Subject: [PATCH 1/1] Fix photo upload from wikidata. --- .../static/catalogue/wikidata_admin.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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); -- 2.20.1