Skip to content

Commit

Permalink
uploadFile fn added
Browse files Browse the repository at this point in the history
  • Loading branch information
TotallyInformation committed Jul 7, 2024
1 parent de5225e commit 684450e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docs/client-docs/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 `<input type="file">` 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]
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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)*
Expand Down

0 comments on commit 684450e

Please sign in to comment.