No more space in Node Red :(

Hi to everybody,
I have a big problem with NR; I am developing an application where I am using, for insert the image in the dashboard, the BASE64 algorithm (I do the decode from BASE64 in image in NR); I want use this solutione because allow me to don't creade folder in the node-red directory full of image.
The problem is...that I don't have enough space anymore for insert the BASE 64 code in the function block..I attach you an image for better explain:

Error:

PayloadTooLargeError: request entity too large
    at readStream (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\raw-body\index.js:155:17)
    at getRawBody (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\raw-body\index.js:108:12)
    at read (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\body-parser\lib\read.js:77:3)
    at jsonParser (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\body-parser\lib\types\json.js:135:5)
    at Layer.handle [as handle_request] (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\express\lib\router\index.js:317:13)
    at C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\express\lib\router\index.js:275:10)
    at cors (C:\Users\carmi\AppData\Roaming\npm\node_modules\node-red\node_modules\cors\lib\index.js:188:7)

This is an example of BASE64 of image that I use :

Block BASE64.txt (152.4 KB)

Please, if you have a solution for enlarge the space in the function block from maybe a setting.js file of node red let me know.......I don't want to delete all my work..

Thanks in advance

Regardless of storing the images as base64 or in separate files, they will take roughly the same amount of disk space. In fact, I would suspect storing the images in the flow as base 64 you will be using more disk space!

If you want to keep them in the flow then you could use a change node for each image and a switch node to direct the flow to the correct change node.

3 Likes

HI Steve,
Thanks for the reply,I tryed now your solution but I have the same problem.

I said...

As in one change node for each image (6 images --> 6 change nodes)

Anyhow, like I said, the image data has to be saved somewhere, so you might as well save them in a file instead of in the flow.

Is it specifically a restriction on using the .node-red directory? You should be able to access files in other directories on your system.

As Steve says, building the images in a function is likely to use much more space than loading them from files.

Yes I know that I can link image inserted in a PC directory, the problem is that I'll need to move always my program from a PC to another, and if I link the Image in a specified directory (ex. C\Steve.nodered\ecc) when I move it in another machine I'll must change always manually the link of the directory (ex. C\John.nodered\ecc).

OK, I'll try. I tested succesfully yet the dashboard printing image from the reading of a .txt BASE64 file.

In any case , as you said, your solution doesn't work too

No you dont. Save the image in a relative folder then DONT specify the full path.

e.g. in the file node use "image1.png" instead of "c:\steve.nodered\image1.png"

Sure it does.

Paste ONE of your image data BASE64 strings in a reply between backticks

```
like this
```

I can't past it in the reply because there are too many words (max 32000) i attach you the .txt file

Block BASE64.txt (152.4 KB)

As I said...

Also, this type of image probably shouldnt be encoded as PNG (PNG is more suited to screenshots not photos or renderings with gradient colours) JPG would be more size friendly.

Lastly, storing such large amounts of data in node-red flow will only make your editor slow. You would be far better off storing the images relative to the node-red installation.

could you kindly write the code of this flow? So now i try to search on the web how to insert Image in the dashboard from a static folder (using as link only \image.png), if you maybe have some link where i can find this solution you would be great.

Thanks for all

Search the forum - this has been done many times.

My recommendation is find something close to what you want, give it a go & when you get stuck on a specific issue, come back & create a thread on that issue.

Your userDir folder can be anywhere that Node-RED can get to it, just set a location in however you start up Node-RED.

For example, you could put the userDir in a synchronised cloud folder.

You could also use soft links to redirect ~/.node-red to a cloud sync'd folder.

Just note that some cloud sync apps don't handle rapidly changing files very well so you might need to pause sync while you use Node-RED and then re-enable it afterwards. Not a problem if you are using a high-speed (e.g. USB-C) external drive.

BTW, Steve is correct a base-64 encoded image is significantly larger than its native file form. Sort out your folders rather than trying to force everything into code. Data images are sometimes used in web pages to reduce the number of http(s) calls that the browser has to do which are relatively slow. This is not the case for getting a file from the file system and sending it to the dashboard via websocket.

Just for the thrill, I added the flow example from @Steve-Mcl to my little dev RPi that I use for all kind of experiments. My flow size increased some 600k. Even if it technically worked, I would for sure never embed large images into a flow, I would keep them outside as already recommended

2 Likes