From 684450ea4ac7740f14a8abac312f85a79213b4a3 Mon Sep 17 00:00:00 2001 From: Julian Knight <1591850+TotallyInformation@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:04:41 +0100 Subject: [PATCH] uploadFile fn added --- docs/client-docs/functions.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/client-docs/functions.md b/docs/client-docs/functions.md index 1098acf0..34bc264b 100644 --- a/docs/client-docs/functions.md +++ b/docs/client-docs/functions.md @@ -3,7 +3,7 @@ title: Functions available in the modern client description: | Details about the functions/methods used in the UIBUILDER front-end client library. Some functions are available to your own custom code and some are hidden inside the `uibuilder` client object. created: 2023-01-28 15:56:57 -updated: 2024-06-21 10:10:44 +updated: 2024-07-07 15:59:16 --- Functions accessible in client-side user code. @@ -148,6 +148,17 @@ uibuilder.onChange('ping', function(data) { }) ``` +### `uploadFile(File)` - Upload a file to Node-RED over Socket.IO :id=uploadFile + +`File` must be a reference to a FileHandler API file object. These can be generated by `` or file drag/drop change events. + +Converts the reference to a Buffer and attempts to send back to Node-RED as a standard message. + +> [!WARNING] +> Socket.IO has a default maximum message size of 1MB. Any file close to this size may fail. The uibuilder client library will issue an error message if the message content is equal to or larger than the current `maxHttpBufferSize` setting. +> +> You can change this by setting an override in Node-RED's `settings.js` file and restarting Node-RED. See the [settings documentation](/uib-configuration#settingsjs) `socketOptions` for details. The client variable `uibuilder.maxHttpBufferSize` contains the current size setting. This is also shown in Node-RED in the initial "client connect" control message. + ## Variable Handling > [!NOTE] @@ -332,7 +343,7 @@ Notes: * Turn on the optional `msg._uib` feature in the UIBUILDER node to see which client is sending the messages. * Due to the nature of the IntersectionObserver API, this fn is not available as a command for now. -### `htmlSend()` - Sends the whole DOM/HTML back to Node-RED :id=htmlSend +### `htmlSend()` - Sends the whole DOM/HTML back to Node-RED :id=htmlSend2 See under [Message Handling](#message-handling) above for details. @@ -912,6 +923,7 @@ Available in front-end JavaScript as `uibuilder.xxxxx` or `uib.xxxxx`. * [`uiEnhanceElement`](#uiEnhanceElement) * [`uiGet`](#uiGet)* * [`uiWatch`](#uiWatch)* +* ['uploadFile'](#uploadFile) * [`urlJoin`](#urlJoin) - Join arguments as a valid URL path string * [`watchDom`](#watchDom) * [`watchUrlHash`](#watchUrlHash)*