ubbase64 – store and retrieve a blob in a table using base64 encoding


ubbase64 –function get|put –attribute <attribute> –key <key> –match <match> {–format csv|json|html|list|textarea|ubxml2pdf} <table>


ubbase64 is used to store and retrieve BLOBs (binary large objects) in a Unibase table.

Typically this is used to store random text and images, but can be used for anything.

The table to be used for storage needs to have a specific format. Two attributes, the first being the index attribute and the second an attribute of 60 characters that is used to store the base64 encoded BLOB.


: note
noteNumber, 6
note, 60

A separate table is normally used to hold meta information about the note.

Unibase guarantees the order of data stored so there is no need to be more specific about the indexes.

To store a BLOB you must specify the function as put and the attribute to store the BLOB in, the key in the table, the match value, and the table name. The format doesn’t matter as the data is jsut stored.

When storing data ubbase64 reads stdin for data.

To retrieve a blob use the function get along with the other attributes.

The retrieved BLOB is output on stdout.

ubbase64 can also format a text BLOB so that it is suitable for display in html (–format html) or for use in a textarea input (–format textarea).

Other formats are

  • csv – character substitutions make the text suitable for use in a csv file
  • html – line feeds (\n) are changed into <br>
  • json – line feeds changed to \n, ” is escaped (\”), / is escaped (\/), \ is escaped (\\)
  • list – lines are output as Tcl list items. ie {<line>}
  • p – data is output without newline. Suitable for inserting in other tags.
  • textarea – output is suitable for editing in html textarea input type
  • textxml – output data between <text></text> tags for ubxml2pdf. \n is replaced with ‘</text></line><line><text>’
  • ubxml2pdf – each line is surrounded by <line><text> … </text></line> making it suitable for use in xml format for ubxml2pdf. Also <, >, and ‘ are replaced by xml safe & sequences (&lt;, &gt;, &quot;).

–format raw or not using the –format flag will return the raw base64 text as the original binary data. eg use this to extract images, spreadsheets, etc.

Multiple output formats can be given as <format 1>+<format 2>+… Each format will be applied to output of the previous format. Order is important.


–attributeattribute used to save BLOB
–function get (retrieve) or put (save)
–format csv, json, html, list, textarea, ubxml2pdf, or raw
These formats are used for retrieved data.
The data can be presented comptaible with the format specified. That includes appropriate character escaping, substituting, etc.
–key name of key to match
–match value to match