Modules · Connectivity · Storage
Storage
Files, form fields and file pickers. Storage models a picked or captured file as a reactive
Storage.File value — its name, MIME type, size in bytes and
Base64-encoded contents — and gives you the inputs, form fields and picker payloads that fill one in.
A file or image input binds to an optional Storage.File state,
so the surrounding view updates the moment the user chooses or clears a file. Files serialise to and from
Code.Language.Json.Value, so a chosen file can travel in a form submission or be
stored and restored.
Contents
Types
Functions
- Storage.File.Data
- Storage.File.FromJson
- Storage.File.FromJsonOptional
- Storage.File.GetBase64Data
- Storage.File.GetFileName
- Storage.File.GetFileSizeBytes
- Storage.File.GetMimeType
- Storage.File.ToJson
- Storage.FormField.File
- Storage.FormField.Image
- Storage.Input.File
- Storage.Input.Image
- Storage.PickerEmit.FromBindings
Types
Storage.File
A picked or captured file: its name, MIME type, size and Base64-encoded contents. It also groups the file operations.
Fields
| Field | Type | Description |
|---|---|---|
fileName | Text | The file's name, including its extension. |
mimeType | Text | The file's MIME type, such as image/png. |
base64Data | Text | The file's bytes, Base64-encoded. |
fileSizeBytes | Maths.Integer | The file's size in bytes. |
Definition
TYPE Storage.File
FIELD Text fileName
FIELD Text mimeType
FIELD Text base64Data
FIELD Maths.Integer fileSizeBytesExample
STATE Collection.Optional(Storage.File) chosen = noneStorage.PickerEmit
The payload a picker sends to the native layer, naming the picker and the state cells it should write back to.
Fields
| Field | Type | Description |
|---|---|---|
pickerType | Text | Which picker to open, such as camera or file. |
fileSettableId | Maths.Integer | Reference to the file state the picker writes the result into. |
visibleSettableId | Maths.Integer | Reference to the visibility state the picker closes when done. |
Definition
TYPE Storage.PickerEmit
FIELD Text pickerType
FIELD Maths.Integer fileSettableId
FIELD Maths.Integer visibleSettableIdStorage.PickerEmit.FromBindings.Functions
Storage.File.Data
Builds a file value from its name, type, contents and size.
Parameters
| Name | Type | Description |
|---|---|---|
fileName | Text | The file's name. |
mimeType | Text | The file's MIME type. |
base64Data | Text | The file's Base64-encoded contents. |
fileSizeBytes | Maths.Integer | The file's size in bytes. |
Returns
Returns Storage.File — a file value carrying the given details.
Example
LET Storage.File file = Storage.File.Data name mime data sizeStorage.File.FromJson
Rebuilds a file from a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
json | Code.Language.Json.Value | The JSON object to read. |
Returns
Returns Storage.File — the file described by json, with missing fields defaulting to empty.
Example
LET Storage.File file = Storage.File.FromJson savedStorage.File.FromJsonOptional
Rebuilds a file from an optional JSON value, staying absent when the input is.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJson | Collection.Optional(Code.Language.Json.Value) | The JSON to read, or nothing. |
Returns
Returns Collection.Optional(Storage.File) — the rebuilt file, or nothing when optionalJson is absent.
Storage.File.GetBase64Data
The file's Base64-encoded contents.
Parameters
| Name | Type | Description |
|---|---|---|
file | Storage.File | The file to read. |
Returns
Returns Text — the file's bytes, Base64-encoded.
Storage.File.GetFileName
The file's name.
Parameters
| Name | Type | Description |
|---|---|---|
file | Storage.File | The file to read. |
Returns
Returns Text — the file's name, including its extension.
Storage.File.GetFileSizeBytes
The file's size in bytes.
Parameters
| Name | Type | Description |
|---|---|---|
file | Storage.File | The file to read. |
Returns
Returns Maths.Integer — the file's size in bytes.
Storage.File.GetMimeType
The file's MIME type.
Parameters
| Name | Type | Description |
|---|---|---|
file | Storage.File | The file to read. |
Returns
Returns Text — the file's MIME type, such as image/png.
Storage.File.ToJson
Serialises a file to a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
file | Storage.File | The file to serialise. |
Returns
Returns Code.Language.Json.Value — a JSON object holding the file's fields.
Storage.FormField.File
A form-integrated file field that registers its value, runs validation and shows errors.
Parameters
| Name | Type | Description |
|---|---|---|
name | Text | The field's name within the enclosing form. |
label | Text | The label shown above the input. |
Block
A validation block run with the field's current value as Collection.Optional(Text) — absent when no file is chosen; report a problem from inside it to mark the field invalid.
Returns
Returns nothing — it renders the labelled field, publishes its value to the form and shows any error or success.
Storage.FormField.Image
A form-integrated image field that registers its value, runs validation and shows errors.
Parameters
| Name | Type | Description |
|---|---|---|
name | Text | The field's name within the enclosing form. |
label | Text | The label shown above the input. |
Block
A validation block run with the field's current value as Collection.Optional(Text) — absent when no image is chosen; report a problem from inside it to mark the field invalid.
Returns
Returns nothing — it renders the labelled field, publishes its value to the form and shows any error or success.
Storage.Input.File
A file input showing the chosen filename and a Select button, bound to a file state.
Parameters
| Name | Type | Description |
|---|---|---|
file | Collection.Optional(Storage.File) | A binding to the file state the input reads and writes; shows “No file chosen” while absent. |
Returns
Returns nothing — it renders the input and updates file when the user picks or clears one.
Example
STATE Collection.Optional(Storage.File) chosen = none
Storage.Input.File chosenchosen cell.Storage.Input.Image
An image input showing the chosen filename and a Select button, bound to a file state.
Parameters
| Name | Type | Description |
|---|---|---|
file | Collection.Optional(Storage.File) | A binding to the file state the input reads and writes; shows “No image chosen” while absent. |
Returns
Returns nothing — it renders the input and updates file when the user picks or clears an image.
Storage.PickerEmit.FromBindings
Packages picker bindings into an emit payload the native picker can write back through.
Parameters
| Name | Type | Description |
|---|---|---|
pickerType | Text | Which picker to open, such as camera or file. |
file | Collection.Optional(Storage.File) | A binding to the file state the picker writes its result into. |
visible | Logic.Maybe | A binding to the visibility state the picker closes when done. |
Returns
Returns Storage.PickerEmit — the payload carrying the picker's type and the referenced state cells.