Working with Binary Data

Images, Icons, Pictures, Documents, Voice, Video, and other binary data can be stored in Live API Creator using various SQL database datatypes (e.g. blobs, clobs). The JSON response format can be modified to return this binary data as either Base64 or Hex (see API Properties/Settings - Binary Output Encoding).  Live API Creator will attempt to return binary data inline if the a) the size is less than the inline limit setting and b) the Force Binary Data as an Object is set not set.  For Base64 return value will either begin with b64: and Hex values will begin with 0x.  

Use the Demo API project sample application. For more information about this API project sample, see Demo.  In the example below, the REST response shows the attribute 'icon' as an object of type base64.  Note that the attribute 'piciture' returns a url instead of a value.  When the object length is greater than the settings 'inline limit' - the URL can be used to retrieve the /data/ portion of that field.

In the REST Lab, select employee_picture and do a GET:
https://localhost:8080/APIServer/rest/el-dev/demo/v1/demo%3Aemployee_picture

The following response is expected:

Note: JSON returns a base64-encoded string (icon) or a link to the actual picture or voice image using a /data/ link instead of a /rest/ link.

employee_id": 1,
    "icon": {
      "type": "base64",
      "length": 1185,
      "value": "iVBORw0KGgoAAAANSUhEUgAAA... (truncated)"
    },
"picture": {
      "type": "base64",
      "length": 138795,
      "url": "https://server.acme.com/data/el-dev/demo/v1/demo:employee_picture/1/picture"
    },
voice": {
      "type": "base64",
      "length": 127187,
      "url": "https://server.acme.com/data/el-dev/demo/v1/demo:employee_picture/1/voice"
    }

Use the following URL:
https://demodev.espressologic.com/data/el-dev/demo/v1/demo:employee_picture/1/picture

The following response is expected:


{
  "0": "�",
  "1": "P",
  "2": "N",
  "3": "G",
  "4": "
",
  "5": "
",
  "6": ".",
  "7": "
",
  "8": "",
  "9": "", truncated ...