How to create, write and save a Javascript File for export

Hello everybody,
I’m new here - maybe there is already a similar question, but I didn’t found it jet.

I would like to create a Javascript-File.
As far as I can see the method: createRenditions doesn’t support the filetype javascript - right?
Is there an other possibility to create and save a javascriptfile in a choosen folder?

And then I also didn’t get how to write a file or how to insert some content in this created file - maybe you can help me with that, too?!

Would be create!
Thanks for any helpful answer!

1 Like

Hi @Jojo,

first of all: Welcome to the forums :wave::slightly_smiling_face:.

The storage module is probably what you’re looking for, it allows saving files (among them, text files like JS):

https://adobexdplatform.com/plugin-docs/reference/uxp/storage-index.html

You can let the user choose a location by using

const lfs =  require('uxp').storage.localFileSystemProvider;

const myFile = await lfs.getFileForSaving('my-file.js', {types: ['js']});

and then write to it (assuming myCode is the Javascript code you want to have in your file):

await myFile.write(myCode);

I hope this helps,
Best,
Pablo

1 Like

Awesome! That’s what I was looking for! :partying_face:
Thank you very much! :pray:

1 Like