How to create a file using javascript?

I am trying to create a file based on user inputs. I have written the following javascript code to generate a file

  const filename = "my_file.txt";
  const content = "Input UserKey's value";
  const blob = new Blob([content], {type: "application/javascript"});
  const file = new File([blob], filename, {type: "application/javascript"});

On javascript to bubble event, I save the file to database
file = JavascripttoBubble A’s value

But I get the following error:

The plugin Toolbox / element Javascript to Bubble threw the following error: Error: Expected a file url as a string, but got a object (original data: {})
at cY.generate_JS_to_bubble_error (
at Object.JS_to_bubble ( (please report this to the plugin author)

Can someone please help me understand where am I going wrong?

Just figured it out. Have to pass the file path.

How do you do that?

Have to create a url and then pass it

Had to scrap the approach, because i wanted files to be public and accessible via browser. Am doing this now via apis.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.