機械翻訳について

バイナリ・コンテンツの受信

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

サンプル・コードは、接続プロパティを使用してAPIホスト情報を受信する方法を示しています。 connectivity::restファンクションは、ペイロードに基づいてレスポンス・コンテンツの処理を暗黙的に決定します。 レスポンスがアタッチメントであり、マルチパートではない場合、この関数はレスポンスをバイナリとして扱います。

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

    サンプル・コード:

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

    サンプル・コード:

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

    サンプル・コード:

    {
             "functionRef": {
               "refName": "httpOutbound",
               "arguments": {
                 "uri": "${.connectionProperties.baseURL + \"/orders\"}",
                 "method": "GET"
               }
             },
             "actionDataFilter": {
               "results": "${ { File: .body} }",
               "toStateData": "${ .output }"
             }
           }
完全なサンプル・コード:
"flows": {  
   "DownloadFileFlow" : {
      "id": "DownloadFileFlow",
      "description": "DownloadFileFlow",
      "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": "GET"
                }
              },
              "actionDataFilter": {
                "results": "${ { File: .body} }",
                "toStateData": "${ .output }"
              }
            }
          ],
          "name": "startState",
          "type": "operation",
          "end": true
        }
      ]
    }
}