How to create a file using javascript?

Hi,
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"});
  bubble_fn_createJSFile(file);

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 (https://contestpool.com/package/run_debug_js/65a27dc5f0f4cf7962bea53b63819536c8a5cda7f34814364c92565f66f72a6c/xfalse/x25/run_debug.js:417:43380)
at Object.JS_to_bubble (https://contestpool.com/package/run_debug_js/65a27dc5f0f4cf7962bea53b63819536c8a5cda7f34814364c92565f66f72a6c/xfalse/x25/run_debug.js:417:65973) (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.