|
@@ -3,6 +3,16 @@ import { isWhitespace } from '@/utils/helper';
|
|
|
import { executeWebhook } from '@/utils/webhookUtil';
|
|
|
import renderString from '../templating/renderString';
|
|
|
|
|
|
+function fileReader(blob) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ const reader = new FileReader();
|
|
|
+ reader.onload = () => {
|
|
|
+ resolve(reader.result);
|
|
|
+ };
|
|
|
+ reader.readAsDataURL(blob);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
export async function webhook({ data, id }, { refData }) {
|
|
|
const nextBlockId = this.getBlockConnections(id);
|
|
|
const fallbackOutput = this.getBlockConnections(id, 'fallback');
|
|
@@ -47,8 +57,13 @@ export async function webhook({ data, id }, { refData }) {
|
|
|
|
|
|
if (data.responseType === 'json') {
|
|
|
const jsonRes = await response.json();
|
|
|
-
|
|
|
returnData = objectPath.get(jsonRes, data.dataPath);
|
|
|
+ } else if (data.responseType === 'base64') {
|
|
|
+ const blob = await response.blob();
|
|
|
+ const base64 = await fileReader(blob);
|
|
|
+
|
|
|
+ console.log(base64);
|
|
|
+ returnData = base64;
|
|
|
} else {
|
|
|
returnData = await response.text();
|
|
|
}
|