Send Binary Content

This procedure shows how to create a flow to send binary content.

The connectivity::rest parameter implicitly determines the response content handling based on payload. If the action's input schema defines input type as binary and if the binary object is body for connectivity::rest, the connectivity::rest parameter treats as a binary stream.

  1. Open the adapter definition document in Visual Studio Code.
  2. Define the action's input schema as binary.

    Sample code:

    "UploadFileRequestSchema": {
       "type": "object",
       "properties": {
         "File": {
           "type": "string",
           "format": "binary"
         }
       }
     },
  3. Refer to the schema in the action as input schema.

    Sample code:

    "UploadFileAction": {
         "description": "",
         "displayName": "upload file",
         "execute": "flow:UploadFileFlow",
         "input": {
           "schemaType": "application/schema+json",
           "schema": {
             "$ref": "#/schemas/UploadFileRequestSchema"
           }
         },
         "output": {
          ...
         }
       },
  4. Create a flow with connectivity::rest operation and pass the .input.File as body.

    Sample code:

    {
                  "functionRef": {
                    "refName": "httpOutbound",
                    "arguments": {
                      "uri": "${.connectionProperties.baseURL + \"/orders\"}",
                      "method": "POST",
                      "body": "${ .input.File}"
                    }
                  },
                  "actionDataFilter": {
                    "results": "${ { body: .body, headers: .headers } }",
                    "toStateData": "${ .output }"
                  }
                }
Complete sample code:
"flows": {  
   "UploadFileFlow" : {
      "id": "UploadFileFlow",
      "description": "UploadFileFlow",
      "version": "0.1",
      "start": "startState",
      "specVersion": "0.8",
      "functions": [
        {
          "name": "httpOutbound",
          "operation": "connectivity::rest",
          "type": "custom"
        }
      ],
      "states": [
        {
          "actions": [
            {
              "functionRef": {
                "refName": "httpOutbound",
                "arguments": {
                  "uri": "${.connectionProperties.baseURL + \"/orders\"}",
                  "method": "POST",
                  "body": "${ .input.File}"
                }
              },
              "actionDataFilter": {
                "results": "${ { body: .body, headers: .headers } }",
                "toStateData": "${ .output }"
              }
            }
          ],
          "name": "startState",
          "type": "operation",
          "end": true
        }
      ]
    }
}