Binary data construction
Syntax
binary(
name: "hello.txt",
data: "Hello World!",
contentType: "text/plain",
encoding: "utf-8"
)
Description
Constructs a binary value (a file) with the specified values. Such a value can be stored in an attribute of type tl.core:Binary
and offered for download.
Parameters
Name | Type | Description | Mandatory | Default |
---|---|---|---|---|
name | String | Name of the file | yes | -/- |
data | Any | File content. If the value is itself a binary value, it will be taken unchanged. If the content type is application/json, a JSON representation will be created for the object. Otherwise, the string representation of the value will be used and stored in the specified character set. | yes | -/- |
contentType | String | MIME type of the file, e.g. "text/plain " for a text file or "application/json " for an object in JSON format. |
no | Derived from the file name. |
encoding | Character string | The character set to use for textual content. Has no meaning for other content. | no | "utf-8 " |
size | Number | Length of binary data, -1 , if not known. |
no | -1 |
Return value
Type: binary value
A representation of a file. In the above example, it is a text file named "hello.txt
" and the content "Hello world!
" encoded in the character set "utf-8
". If the value is used as a return value of a custom action of a button, the data will be offered to the user as a download.