From 8992a856192ee0256e57d077d0b1c1ba74c6cecc Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Mon, 27 Nov 2023 13:44:19 +0100 Subject: [PATCH] Update 0BDFDB.plugin.js --- Library/0BDFDB.plugin.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 9462c360eb..79ad936c49 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -213,9 +213,16 @@ module.exports = (_ => { response.statusCode = response.status; if (response.headers) response.headers["content-type"] = response.headers.get("content-type"); BDFDB.TimeUtils.clear(timeoutObj); - return config.toBuffer ? response.arrayBuffer() : response.text(); - }).then(body => { - if (!killed && response) callback(response.status != 200 ? new Error(response.statusText || "Fetch Failed") : null, response, body); + return config.toBase64 ? response.blob() : config.toBuffer ? response.arrayBuffer() : response.text(); + }).then(result => { + if (!killed && response) { + if (!config.toBase64 || response.status != 200) callback(response.status != 200 ? new Error(response.statusText || "Fetch Failed") : null, response, result); + else { + let reader = new FileReader(); + reader.onload = _ => callback(null, response, reader.result); + reader.readAsDataURL(result); + } + } }); } };