機械翻訳について

バイナリ・コンテンツを送信

この手順は、バイナリ・コンテンツを送信するフローを作成する方法を示しています。

connectivity::restパラメータは、ペイロードに基づいてレスポンス・コンテンツの処理を暗黙的に決定します。 アクションの入力スキーマが入力タイプをバイナリとして定義し、バイナリ・オブジェクトがconnectivity::restの本文である場合、connectivity::restパラメータはバイナリ・ストリームとして処理されます。

  1. Visual Studio Codeでアダプタ定義ドキュメントを開きます。
  2. アクションの入力スキーマをbinaryとして定義します。

    サンプル・コード:

    "UploadFileRequestSchema": {
       "type": "object",
       "properties": {
         "File": {
           "type": "string",
           "format": "binary"
         }
       }
     },
  3. アクション内のスキーマを入力スキーマとして参照します。

    サンプル・コード:

    "UploadFileAction": {
         "description": "",
         "displayName": "upload file",
         "execute": "flow:UploadFileFlow",
         "input": {
           "schemaType": "application/schema+json",
           "schema": {
             "$ref": "#/schemas/UploadFileRequestSchema"
           }
         },
         "output": {
          ...
         }
       },
  4. connectivity::rest操作を使用してフローを作成し、.input.Fileを本文として渡します。

    サンプル・コード:

    {
                  "functionRef": {
                    "refName": "httpOutbound",
                    "arguments": {
                      "uri": "${.connectionProperties.baseURL + \"/orders\"}",
                      "method": "POST",
                      "body": "${ .input.File}"
                    }
                  },
                  "actionDataFilter": {
                    "results": "${ { body: .body, headers: .headers } }",
                    "toStateData": "${ .output }"
                  }
                }
完全なサンプル・コード:
"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
        }
      ]
    }
}