node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

File Input: Add examples

Open github-cyprien opened this issue 1 year ago • 2 comments

Description

It could be nice to add example flows for the new File Input widget. Flows could be

  • Upload a .txt file and show it in debug
  • Upload a .csv file and show it in table
  • Upload an image file and show it in template and/or in markdown

I'd like to do it, but i think i need some help...

Have you provided an initial effort estimate for this issue?

I am no FlowFuse team member (Unfortunately ;))

github-cyprien avatar Jun 23 '24 16:06 github-cyprien

Agree - currently, it uploads an ArrayBuffer which would need converting.

@Steve-Mcl what's your recommendation here? Feel like we should handle this conversion within the node for basic file types (text/image). Not sure what the standard conversion process is for Node-RED?

joepavitt avatar Jun 24 '24 15:06 joepavitt

@Steve-Mcl what's your recommendation here? Feel like we should handle this conversion within the node for basic file types (text/image). Not sure what the standard conversion process is for Node-RED?

For images and other binary types, it is my opinion that these should be left as binary. Often, the user will be simply passing the payload on or perhaps saving the image/data to file/db.

For the times when a user does want to display an uploaded image in dashboard there are plenty of nodes and built in JS for conversion to Base64 string (Base64 node, node-red-contrib-image-tools, Function node Buffer.from(payload).toString('base64') etc)) etc.

That keeps things atomic and sticks to the mantra "a node should do one thing and do it well"

The thing is, images are H E A V Y so processing them unnecessarily would lock us in to supporting that for ever more (even if it is rarely used or even wanted)

So, this is where the built in examples come in super useful and the 3 proposed examples are spot on. I would possibly add 1 more (or change the upload a .txt file to) uploading a markdown file and displaying it in the MD widget.

Steve-Mcl avatar Jun 27 '24 07:06 Steve-Mcl