File write node error

Hi

With the below flow using executables, I am creating a JSON file in Losant edge agent, and when I try to write data into that file using File Write, it says permission is denied also when I pass ls -lh command to see the file it is not showing up.

When you started up the agent, did you mount the file or its parent directory into the Docker container? That must be done in order to read and write from the agent.

We mention this in our docs for the File: Tail Trigger and also in the GEA usage page; I will file a ticket about getting that added to the Read / Write Node docs as well.

Here is Docker’s documentation on mounting volumes into the container and things to consider:

I am using the /home directory in the GEA. I have not tried mounting any directory. I will try to mount one and let you know.

I tried mounting onchange directory into home, like /home/onchange and again, if I put a file into that directory, I am getting below error.

Can you provide the full docker command you are using to start the container, making sure to redact any sensitive info that may be in it such as access keys?

And this is a Linux environment, correct?

Are you able to read/write to /home/losant/onchange.json? That is a directory you should have permissions for without any mounting.

yes it does Thanks for the support

So, Is it possible to read/write in .txt or .json format files using File Read/Write node? because the encoding only supports UTF and when I read it, I get object object in the debug

What’s most likely happening is the file content is getting written as [object Object]. If you have an object on your payload and you are trying to write that object to a file, you need to use the {{jsonEncode}} helper or a JSON: Encode Node to stringify that object before it is provided to the File: Write Node as the contents.

Then, when reading, if you want to operate on the file contents as an object, you’ll need to follow up the File: Read Node with a JSON: Decode Node to parse it.

If this is something you will be doing often across multiple workflows, you may want to consider wrapping all of this in a Custom Node.

Yes. Its working as expected. Thanks