# Create a jpeg from camera snapshot URL - not working

**URL:** <https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194>\
**Category:** General\
**Created:** [22 October 2018 18:13 UTC](https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194 "2018-10-22T18:13:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [22 October 2018 18:13 UTC](https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194/1 "2018-10-22T18:13:08Z")

</div>

Hi,

I have a foscam camera that provides a screenshot via the following url,

```
 http://192.168.1.170/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=myusername&pwd=mypassword

```

this then feeds into the following function which then goes into an email node. (I found this on the old google group forum, so it’s not something I have built myself)

```
[{"id":"24bd4c05.ab64a4","type":"change","z":"7141ede8.f151a4","name":"Flow 4 : Setup mail content","rules":[{"t":"set","p":"attachments","pt":"msg","to":"[{\t \"filename\": 'camera_snapshot.jpg', \t \"path\": '/tmp/local_image.jpg',\t \"content\": $$.payload\t}]","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"Result flow 4","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"Dear,<br><br>Your PIR detector has detected movement in the living room.<br>In attachment you can find the file that was locally stored.<br><br>Kind regards,<br>Your Node-Red flow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":480,"wires":[["8cde2b21.2ff708"]]}]

```

The problem I have is that the email created has a jpg file attached but it is not visible.when I try to open it.

Any ideas,

---

<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:** [22 October 2018 18:20 UTC](https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194/2 "2018-10-22T18:20:54Z")

</div>

add debug nodes along the flow and check that the message being passed between the nodes looks correct.

Try saving the image using the file-out node, You really need to work out where along the flow it isn't working

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [22 October 2018 18:24 UTC](https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194/3 "2018-10-22T18:24:33Z")

</div>

Hi,

My flow has a debug, and it also tries to write the file to a local store too, which I can see in the directory - but when I try to open that - it does not open to something I can see.

Within one program i tried - I just get an exclamation mark come up, no other message.

It seems to create a file, of about 128kb; with a jpg extension but it’s it’s not something I can open/see.

Here is the flow..

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/87231ee70e1d0f936af6fdc9c91b54a08e56d513.jpeg)

The debug create a string something like the following.  
_To save space just the first part is provided below._

> ����JFIF��� ' .)10.)-,3:J\>36F7,-@WAFLNRSR2\>ZaZP`JQRO&&O5-5OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO&&O5-5OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

---

<div class="post-metadata">

**Author:** ![moebius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/moebius/32/2872_2.png) [@moebius](https://discourse.nodered.org/u/moebius)\
**Post date:** [22 October 2018 19:16 UTC](https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194/4 "2018-10-22T19:16:08Z")

</div>

Did you set the return value of the http request to "a binary buffer"?

---

<div class="post-metadata">

**Author:** ![nodecentral](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodecentral/32/10432_2.png) [@nodecentral](https://discourse.nodered.org/u/nodecentral)\
**Post date:** [22 October 2018 19:27 UTC](https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194/5 "2018-10-22T19:27:15Z")

</div>

That did it !! Thanks @moebius

It works great now.

What does that binary buffer option do ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 October 2018 20:08 UTC](https://discourse.nodered.org/t/create-a-jpeg-from-camera-snapshot-url-not-working/4194/6 "2018-10-22T20:08:48Z")

</div>

> [@nodecentral](#):
>
> What does that binary buffer option do

It tells it to leave it as the raw binary data rather than trying, for example, to convert it to a string.
