From 0ac80e8387a69924284259bde448af2813d84ed1 Mon Sep 17 00:00:00 2001 From: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Date: Wed, 21 Oct 2020 08:41:09 -0600 Subject: [PATCH] feat: support WKWebview custom protocol (#1113) --- frontend/src/api/files.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index b3177c9d..08f0d84a 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -85,6 +85,11 @@ export function download (format, ...files) { export async function post (url, content = '', overwrite = false, onupload) { url = removePrefix(url) + let bufferContent + if (content instanceof Blob && !['http:', 'https:'].includes(window.location.protocol)) { + bufferContent = await new Response(content).arrayBuffer() + } + return new Promise((resolve, reject) => { let request = new XMLHttpRequest() request.open('POST', `${baseURL}/api/resources${url}?override=${overwrite}`, true) @@ -108,7 +113,7 @@ export async function post (url, content = '', overwrite = false, onupload) { reject(error) } - request.send(content) + request.send(bufferContent || content) }) }