Create text file

Create text file

  
What is the best way to create an simple text file with some content? Is there an extension for this or is it necessary to create one?
Hi Pedro,

Indeed, you'll need an extension to write text to a file.
We've already created one extension that I attached to this post, with the source code included, and I've also attached a sample OML to show you how to use it.
The sample is a simplified use-case, reading and writing the files locally on the hub node.

Note that the extension is provided «as is».
Feel free to use it, and all other extension features (file copy/move/delete, directory listing/creation, etc.)

I hope this will help you,
Olivier Carneiro
Cannot create text file in my local computer ...it tells me the file does not exist ....when you say "hub node" ... it means that the file can only be created in the "hub server" ...not in my local machine?!

the sample cannot create the text file ....neither retrive it for reading.

PS: yes , i publish the extension!
Cannot create text file in my local computer ...it tells me the file does not exist ....when you say "hub node" ... it means that the file can only be created in the "hub server" ...not in my local machine?!

the sample cannot create the text file ....neither retrive it for reading.

PS: yes , i publish the extension!
Hi Gilberto,

Consider the web paradigm. You'll have a server serving the web pages and a client, in this case a browser in your local machine. The communication between them is done via the HTTP protocol.

When you program actions in Service Studio, actually you're creating code that runs on the server side of this communication, so when you use a CreateFile action it's actually trying to create that text file on the path you specify but on the server machine not on client's local machine. Javascript on the other way, it's code that will run on the client side. But javascript doesn't have file support.

To be able to create a file in the client's machine you'll need to use another solution that may pass by using an activex that allows access to your local machine or a java applet to do the same. Browser manufacturers have introduced a lot of restrictions in doing these type of things because it imposes high security vulnerabilities. Normally you'll have to sign your activex or applets an rely on client's browser configuration to allow that code to be ran.

With all this said I think that, perhaps, you could be well with a download of a text file rather then trying to create it on the client's machine.

Hope this was helpful. Cheers,
André