# Defect base64 string

**URL:** https://discourse.nodered.org/t/defect-base64-string/66084
**Category:** Dashboard
**Created:** [5 August 2022 16:46 UTC](https://discourse.nodered.org/t/defect-base64-string/66084 "2022-08-05T16:46:56Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![schnello](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/schnello/32/65802_2.png) [@schnello](https://discourse.nodered.org/u/schnello)
#### Post date: [5 August 2022 16:46 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/1 "2022-08-05T16:46:56Z")

</div>

Hello.

I convert images in base64 via bash. The target is to send this base64 string to node-red via http... and display the image on the dashboard.

I send the content of TEST1 with:  
curl --data-binary "@TEST1" [http://192.168.1.133:1880/nodeRed/LG200](http://192.168.1.133:1880/nodeRed/LG200)

The content of TEST1:  
att1=/9j/4AAQSkZ................BQX54B9V+H1AAI8RyE0NiAoL88AX............

Importand part is the V+H

The code in the Template Node:  
`<img src="data:image/jpg;base64,{{payload.att1}}" width="500" height="600">`

I took a look at the source code to see why the image isn't showing  
The image data is placed with  
`data:image/jpg;base64,.....54B9V H1AAI....`  
instead of:  
`..... src="data:image/jpg;base64,.....54B9V+H1AAI...." .......`

The flow:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d0c743e43dbd5b112903e5052a0060e1451652a.png)  
Code:

> <https://gist.github.com/schnello/ea4bf8b58867eca56f4a0d861b70c51e>

What i do wrong?

---

<div class="post-metadata">

### Author: ![schnello](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/schnello/32/65802_2.png) [@schnello](https://discourse.nodered.org/u/schnello)
#### Post date: [5 August 2022 17:14 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/2 "2022-08-05T17:14:17Z")

</div>

Update:  
I add now a "String" node and replace all " " with "+".

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/f/3f4fad396b8819d94a1419322c223042c094ec1a.png)

Works but i guess this is a "stupid solution"

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [5 August 2022 20:49 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/3 "2022-08-05T20:49:36Z")

</div>

> [@schnello](#):
>
> {{payload.att1}}

Try it like:

```auto
{{{payload.att1}}}

```

See the documentation tab for the template node:

> By default, _mustache_ will escape any non-alphanumeric or HTML entities in the values it substitutes. To prevent this, use `{{{triple}}}` braces.

---

<div class="post-metadata">

### Author: ![schnello](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/schnello/32/65802_2.png) [@schnello](https://discourse.nodered.org/u/schnello)
#### Post date: [6 August 2022 06:30 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/4 "2022-08-06T06:30:23Z")

</div>

Hello.

This was my first try:  
`<img src="data:image/jpg;base64,{{{payload.att1}}}" width="450" height="450">`

doesn't help. Base64 string is still defect

Tripple {{{}}}

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/5701849185cd18c7158749a82ed23e6d58e03b49.png)

With the string node (and OK):

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6b23c35065cdfdcdbfcbe699ddf6d7af9089bf1.png)

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [6 August 2022 06:46 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/5 "2022-08-06T06:46:20Z")

</div>

I imported your flow and i notice that in the **template** node (the one that is wired to the **ui\_template** node) .. you had it set as `msg.payload` instead of `msg.template`

Try making the change and see what you get ( with triple brackets )

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/df7ae7464a0c552e2d0773c9d635ddf111c4c244.png)

.. also wire a **complete msg Debug node** after the _template_ ( the orange one 😉 ) to double check if the base64 is rendered as expected and that its not something with the angularjs `ng-bind-html`

---

<div class="post-metadata">

### Author: ![schnello](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/schnello/32/65802_2.png) [@schnello](https://discourse.nodered.org/u/schnello)
#### Post date: [6 August 2022 07:03 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/6 "2022-08-06T07:03:53Z")

</div>

The same.

I guess the main issue is directly after the HTTP Post Node.

If i send with  
`curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "@test" http://192.168.1.30:1880/LG200` the content from file "test"... is there any special format required.

Atm the content is:  
`att1=/9j/4AAQSkZJRgABAQEA8ADwAAD//gBpRmlsZSBzb3VyY2U6IGh0dHA6Ly9jb21tb25zLndpa2ltZWRpYS...............`

---

<div class="post-metadata">

### Author: ![schnello](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/schnello/32/65802_2.png) [@schnello](https://discourse.nodered.org/u/schnello)
#### Post date: [6 August 2022 07:14 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/7 "2022-08-06T07:14:07Z")

</div>

I changed now the content to JSON  
{"att1":"/9j/4AAQSkZJRgABAQEA8ADwAAD//gBpRmlsZSBzb3VyY2U6IGh0dHA6Ly9jb21tb25zLndpa2ltZWRpYS..............."}

looks like this works

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [5 September 2022 07:14 UTC](https://discourse.nodered.org/t/defect-base64-string/66084/8 "2022-09-05T07:14:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
