Browse Source

feat: support base64 in http request block form data

Ahmad Kholid 2 years ago
parent
commit
370722dda0
2 changed files with 14 additions and 5 deletions
  1. 1 1
      package.json
  2. 13 4
      src/workflowEngine/utils/webhookUtil.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.24.2",
+  "version": "1.24.3",
   "description": "An extension for automating your browser by connecting blocks",
   "repository": {
     "type": "git",

+ 13 - 4
src/workflowEngine/utils/webhookUtil.js

@@ -29,11 +29,20 @@ const renderContent = async (content, contentType) => {
         formContent = await getFile(path, { returnValue: true });
 
         if (!filename) {
-          const { pathname } = new URL(path);
-          filename = pathname.split('/').pop();
+          filename = path.split('/').pop();
         }
-      } else if (path.includes('base64')) {
-        const response = await fetch(path);
+
+        if (!formContent) throw new Error('File not found');
+      } else {
+        let base64Str = '';
+
+        if (path.includes('base64')) {
+          base64Str = path;
+        } else {
+          base64Str = `data:text/plain;base64,${window.btoa(path)}`;
+        }
+
+        const response = await fetch(base64Str);
         const result = await response.blob();
 
         formContent = result;