• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
      • HTML in CSPro
      • Markdown Use in CSPro
      • Markdown Syntax
      • Localhost URL
      • Data URL
      • External Libraries
      • JSON Primer
      • HTML Dialog Boxes
      • JavaScript Interface (deprecated)
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Data URL

A data URL is a type of URI where the type of data, and the data itself, is included in the URL. When accessing a data URL, no request to a server is made since all content is embedded in the URL. Data URLs are generally used as a replacement for small files, as they become unwieldy when used with large content.
CSPro can create data URLs when serializing binary data, including the data of binary dictionary items when writing to JSON, or when using the Action Invoker with binary data. The data URLs that CSPro creates are encoded in Base64 and look like:
data:MIME-type;base64,content
For example:
Document doc = "Data URLs added to CSPro 8.0.";
doc.
getValueJson(serializationOptions := "{ \"binaryDataFormat\": \"dataUrl\" }") // returns the binary data as:
data:text/plain;base64,RGF0YSBVUkxzIGFkZGVkIHRvIENTUHJvIDguMC4=
Clicking on that link, or copying and pasting that link into a web browser's address bar, will show the text "Data URLs added to CSPro 8.0."
Generally when using CSPro to create URLs with content, you will want to use localhost URLs, which are faster to create and more efficient. A localhost URL is temporary, only valid while the CSPro application is running, so a data URL may be a good choice if you need a URL that can permanently refer to the data. Data URLs are approximately 33% larger than the content itself, so using data URLs for large files is not advised.
See also: HTML in CSPro, Localhost URL