0

我正在使用 NodeJS AWS SDK 文本来检测图像(图像文件点 PNG/JPG)。它在 AWS EC2 上运行。但它不适用于 AWS Lambda 函数。

我得到了回应:

    {
        "err": {
            "message": "Request has unsupported document format",
            "code": "UnsupportedDocumentException",
            "time": "2019-12-07T08:49:52.788Z",
            "requestId": "fbd1cab5-d725-4f79-ac15-1f033e82aa79",
            "statusCode": 400,
            "retryable": false,
            "retryDelay": 37.87986431208581
        },
        "stack": "UnsupportedDocumentException: Request has unsupported document format\n    at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/json.js:51:27)\n    at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)\n    at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)\n    at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)\n    at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)\n    at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)\n    at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10\n    at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)\n    at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:685:12)\n    at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
    }
4

1 回答 1

0

似乎 lambda 不是通过 JSON 事件调用的,有两个可能的原因,

更好地展示你如何调用 lambda

无效请求内容异常

The request body could not be parsed as JSON.

HTTP Status Code: 400

不支持的媒体类型异常

The content type of the Invoke request body is not JSON.

HTTP Status Code: 415

Lambda-API_Invoke

处理 lambda 集成中的错误

于 2019-12-07T09:50:36.680 回答