I trying to read binary data and send it to other nodes. In this example, I’ll send the data as a message to Telegram.
Basic setup:
Read Binary File > Telegram
In the telegram, I try to send a message using the data read from the file as part of it., but I can’t do that. When I select to read the raw data in the path(assuming data was saved in the data key): Nodes > Read Binary Files > Output Data > Binary > data > [More button] Raw value, just like the picture above:
But when I select it, It doesn’t show the binary file, but some JS object representation:
{{$node["Read Binary File"].binary.data}}
that evaluates to {"mimeType":"text/plain","fileName":"TODO"} instead of the contents.
I tried other options but I couldn’t get the data.
You first have to use the Move Binary Data Node to move the data from binary to json. As soon as you did that, is it available in the Expression-Editor.
I see, using the move from binary to create a JSON that contains the data in a key.
But this seems odd to me. Maybe it has as technical reason for that, but wouldn’t be better if instead of using an extra node for that, this kind of data would be available directly?
For instance, if the binary > data could have a field with the acutal data, instead of using a extra node for that? This would be way better and would make more sense. I can even volunteer to implement this as a PR.
Sure, it would be easier in your single specific use case but as the node says does it read binary data which would normally not make sense loading it directly into the json data. For that reason does it get loaded to the binary data.
So it makes sense for a few use-cases but not for most other ones. Lets say makes sense for text-files, does not make any sense for xls, png, pdf, jpg, mov, mp3, … does it make sense for csv, not so sure, really depends.
And even for the text-file, does it really depend what exactly you are doing with the data afterward. If you need the content directly, you want it in json, but if you want to upload it directly to Dropbox or send it as a file via HTTP, not so much.
I am trying to get data from the webscraper.io API. I get a file with json inside.
How can I turn the binary file containing json into json ? And get each row one by one to fill in a database ?
I tried a Move Binary data node but it doesn’t realy turn the binary into json as I thought it would (my missunderstanding)
If the file would be JSON it would work but in this case, does it look like it is not. At least the screenshot you posted above is not valid JSON. Do they have different output formats and maybe one of them returning actual valid JSON?
Sounds good. Would also be possible to make it work with their strange one JSON object per line format but would require some custom code in a Function-Node. Wonder why they do not simply return an array like every other REST API.