# Foscam databuffer to file

**URL:** <https://discourse.nodered.org/t/foscam-databuffer-to-file/3893>\
**Category:** General\
**Created:** [11 October 2018 14:07 UTC](https://discourse.nodered.org/t/foscam-databuffer-to-file/3893 "2018-10-11T14:07:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [11 October 2018 14:07 UTC](https://discourse.nodered.org/t/foscam-databuffer-to-file/3893/1 "2018-10-11T14:07:59Z")

</div>

I am not the first and i gues not the last one fighting with this 😉

With a lot of help from google i am able to get an output from the snapPicture function  
This gives me a buffer full of data.  
But how can i get this to readable data like test.jpg?  
Tried all settings of the file node but without succes

The setup that i have now is this:

```
[{"id":"587160d6.67c138","type":"function","z":"3160ccff.45e684","name":"","func":"\n var camera={\n \"hostname\":\"123.123.0.123:88\",\n \"uid\":\"user\",\n \"pwd\":\"pass!\"\n }\n\n msg.url=\"http://\"+camera.hostname+\"/snapPicture.cgi?user=\"+camera.uid+\"&pwd=\"+camera.pwd;\n\n return msg;","outputs":1,"noerr":0,"x":553,"y":1001,"wires":[["ee9b6602.8d85f8"]]},{"id":"ee9b6602.8d85f8","type":"http request","z":"3160ccff.45e684","name":"","method":"GET","ret":"bin","url":"","tls":"","x":703,"y":1000,"wires":[["58e6c7d1.0a8d1"]]},{"id":"69b1c7d0.bcd688","type":"inject","z":"3160ccff.45e684","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":340,"y":1000,"wires":[["587160d6.67c138"]]},{"id":"58e6c7d1.0a8d1","type":"file","z":"3160ccff.45e684","name":"","filename":"/home/pi/.node-red/test.jpg","appendNewline":false,"createDir":false,"overwriteFile":"true","x":960,"y":1000,"wires":[[]]}]
```

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [11 October 2018 14:19 UTC](https://discourse.nodered.org/t/foscam-databuffer-to-file/3893/2 "2018-10-11T14:19:54Z")

</div>

maybe helpfull, the output:

```
[60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101,110,99,111,100,105,110,103,61,34,105,115,111,45,56,56,53,57,45,49,34,63,62,10,60,33,68,79,67,84,89,80,69,32,104,116,109,108,32,80,85,66,76,73,67,32,34,45,47,47,87,51,67,47,47,68,84,68,32,88,72,84,77,76,32,49,46,48,32,84,114,97,110,115,105,116,105,111,110,97,108,47,47,69,78,34,10,32,32,32,32,32,32,32,32,32,34,104,116,116,112,58,47,47,119,119,119,46,119,51,46,111,114,103,47,84,82,47,120,104,116,109,108,49,47,68,84,68,47,120,104,116,109,108,49,45,116,114,97,110,115,105,116,105,111,110,97,108,46,100,116,100,34,62,10,60,104,116,109,108,32,120,109,108,110,115,61,34,104,116,116,112,58,47,47,119,119,119,46,119,51,46,111,114,103,47,49,57,57,57,47,120,104,116,109,108,34,32,120,109,108,58,108,97,110,103,61,34,101,110,34,32,108,97,110,103,61,34,101,110,34,62,10,32,60,104,101,97,100,62,10,32,32,60,116,105,116,108,101,62,52,48,52,32,45,32,78,111,116,32,70,111,117,110,100,60,47,116,105,116,108,101,62,10,32,60,47,104,101,97,100,62,10,32,60,98,111,100,121,62,10,32,32,60,104,49,62,52,48,52,32,45,32,78,111,116,32,70,111,117,110,100,60,47,104,49,62,10,32,60,47,98,111,100,121,62,10,60,47,104,116,109,108,62,10]
```

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [11 October 2018 14:29 UTC](https://discourse.nodered.org/t/foscam-databuffer-to-file/3893/3 "2018-10-11T14:29:41Z")

</div>

What are you trying to do with the data?  
Generally an image file as a buffer can be saved to a file.

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [11 October 2018 14:36 UTC](https://discourse.nodered.org/t/foscam-databuffer-to-file/3893/4 "2018-10-11T14:36:02Z")

</div>

i try to save it to a file, a jpg file using a file node.  
i creates a file, 460 bytes when i try to open it it give me an error that it is a wrong file

---

<div class="post-metadata">

**Author:** ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)\
**Post date:** [11 October 2018 14:46 UTC](https://discourse.nodered.org/t/foscam-databuffer-to-file/3893/5 "2018-10-11T14:46:52Z")

</div>

it seems that my call was wrong, the correct call is  
msg.url="http://"+camera.hostname+"/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr="+camera.uid+"&pwd="+camera.pwd

this gives me an image in my browser and i am able to safe it now to disk 😉
