Output payload as binary to file output node

1,200 views
Skip to first unread message

Kevin Jones

unread,
Sep 24, 2014, 8:36:02 AM9/24/14
to node...@googlegroups.com
Greetings again.  Great forum here and excellent participation.

This is a follow up to a previous post regarding binary data from a HTTP POST response.  I've got that part figured out now.  The byte counts are correct for content I am retrieving.  I am retrieving dynamic binary from a web service, so it was not as easy as just downloading a target image/media.

Now, I have a payload of 117341 bytes that is being output as 225548 bytes when using the file output node.  I have newline OFF and overwrite ON.

Ideas of how to ensure the 117341 bytes are written to the file verbatim?

Is there perhaps the need for "verbatim" or string type property to direct the output format?

Thank you in advance!

Dave C-J

unread,
Sep 24, 2014, 4:10:28 PM9/24/14
to node...@googlegroups.com
Hi,

I suspect (if you are using our http node) that although the size may be right it may still have messed with the contents... (at least it did when I was trying it here)...  

yes there is also a problem with the file writer... again it's not handllng binary properly... only for some reason it's a lo more pronounced here.

Am looking into it.

Nicholas O'Leary

unread,
Sep 24, 2014, 4:15:37 PM9/24/14
to node...@googlegroups.com
Hi Kevin,

I have just done a simple test of File-In node -> Change node that deletes msg.filename -> File-Out node and it properly copies the file contents as you'd expect. So I think the File-Out node is working properly. (Although interested to see what issues Dave has just mentioned...)

You say you're retrieving the payload via an HTTP Request - as per the other thread on that issue, we don't currently handle non-utf8 responses properly. So I wanted to check how you are retrieving the payload and whether your certain it's getting into node-red as you expect? Here's a Function/Debug node pair you can use to check the length of the Buffer object held in msg.payload - if you haven't already, that would be a useful sanity check that payload is what you think it is in the flow. Import the follow (ctrl-I, then paste this in):

    [{"id":"6b6c2265.9493dc","type":"function","name":"","func":"msg.payload = msg.payload.length;\nreturn msg;","outputs":1,"x":610,"y":240,"z":"446f8066.bb908","wires":[["b73b56e5.48c4a8"]]},{"id":"b73b56e5.48c4a8","type":"debug","name":"","active":true,"console":"false","complete":"false","x":750,"y":240,"z":"446f8066.bb908","wires":[]}]

Nick


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Sep 24, 2014, 4:25:37 PM9/24/14
to node...@googlegroups.com
Nick
when the http request node outputs it's a string - (even though it contains non-ascii chars) so it doesn't get handled as a buffer - if you pass in a buffer it is ok ..

Dave C-J

unread,
Sep 26, 2014, 4:24:40 PM9/26/14
to node...@googlegroups.com
Hi Kevin,

I have pushed a fix for the file node to now force it to write binary instead of utf8 - which should help that half of the problem... 
Reply all
Reply to author
Forward
0 new messages