機械翻訳について

マルチパート・コンテンツの送信

この手順は、マルチパート・コンテンツを送信するフローの作成方法を示しています。

connectivity::restパラメータは、コンテンツ・タイプがmultipart/*で本文がパートの配列であるマルチパートとして、リクエストを暗黙的に処理します。

  1. Visual Studio Codeでアダプタ定義ドキュメントを開きます。
  2. キー値を使用してアクション入力および出力スキーマを定義します。

    サンプル・コード:

    "UploadFileRequestSchema": {
         "type": "object",
         "properties": {
           "File": {
             "type": "string",
             "format": "binary"
           },
           "FileMetadata": {
             "type": "object",
             "properties": {
               "title": {
                 "type": "string"
               },
               "mimeType": {
                 "type": "string"
               },
               "description": {
                 "type": "string"
               }
             }
           }
         }
       }
  3. 処理のスキーマを入力および出力スキーマとして参照します。

    サンプル・コード:

     "UploadFileAction": {
         "description": "",
         "displayName": "upload file",
         "execute": "flow:UploadFileFlow",
         "input": {
           "schemaType": "application/schema+json",
           "schema": {
             "$ref": "#/schemas/UploadFileRequestSchema"
           }
         },
         "output": {
           ...
           }
         }
       }
  4. connectivity::restパラメータを使用してフローを作成し、PARTオブジェクトの配列を使用して本文を定義します。

    サンプル・コード:

    {
                  "functionRef": {
                    "refName": "httpOutbound",
                    "arguments": {
                      "uri": "${.connectionProperties.baseURL + \"/upload/drive/v2/files\"}",
                      "method": "POST",
                      "body": [
                        {
                          "Content-Type": "text/plain",
                          "Content-Disposition": "form-data; name=\"metadata\"",
                          "Content": "${ .input.FileMetadata }"
                        },
                        {
                          "Content-Type": "${ .input.FileMetadata.mimeType }",
                          "Content-Disposition": "${ \"form-data; name=\\\"file\\\"\"}",
                          "Content": "${ .input.File }"
                        }
                      ]
                    }
                  },
                  "actionDataFilter": {
                    "results": "${ .body } }",
                    "toStateData": "${ .output }"
                  }
                }
完全なサンプル・コード:
"flows": {   
      "UploadFileFlow": {
      "id": "UploadFileFlow",
      "version": "0.1",
      "start": "startState",
      "specVersion": "0.8",
      "functions": [
        {
          "name": "UploadFileFunction",
          "operation": "connectivity::rest",
          "type": "custom"
        }
      ],
      "states": [
        {
          "name": "startState",
          "type": "operation",
          "actions": [
            {
              "functionRef": {
                "refName": "httpOutbound",
                "arguments": {
                  "uri": "${.connectionProperties.baseURL + \"/upload/drive/v2/files\"}",
                  "method": "POST",
                  "body": [
                    {
                      "Content-Type": "text/plain",
                      "Content-Disposition": "form-data; name=\"metadata\"",
                      "Content": "${ .input.FileMetadata }"
                    },
                    {
                      "Content-Type": "${ .input.FileMetadata.mimeType }",
                      "Content-Disposition": "${ \"form-data; name=\\\"file\\\"\"}",
                      "Content": "${ .input.File }"
                    }
                  ]
                }
              },
              "actionDataFilter": {
                "results": "${ { body: .body, headers: .headers } }",
                "toStateData": "${ .output }"
              }
            }
          ],
          "end": true
        }
      ]
    }
}