如何使用JavaScript调用AWS Textract服务来上传本地照片以供识别(不含S3)

如何使用JavaScript调用AWS Textract服务来上传本地照片以供识别(不含S3),javascript,node.js,amazon-web-services,Javascript,Node.js,Amazon Web Services,我想调用AWS Textract服务来识别JavaScript(不含S3)中本地照片中的数字,但我得到了一个错误 TypeError:无法读取未定义的属性“bytellength”:在“Client.send(command)”中出错 我试图在AWS SDK for JavaScript V3官方文档中找到正确的示例,但没有找到 我想知道如何修改代码来调用此服务 这是我的密码 const { TextractClient, AnalyzeDocumentCommand } = requi

我想调用
AWS Textract
服务来识别JavaScript(不含S3)中本地照片中的数字,但我得到了一个错误
TypeError:无法读取未定义的属性“bytellength”:在“Client.send(command)”中出错

我试图在AWS SDK for JavaScript V3官方文档中找到正确的示例,但没有找到

我想知道如何修改代码来调用此服务 这是我的密码

const {
  TextractClient,
  AnalyzeDocumentCommand
} = require("@aws-sdk/client-textract");
// Set the AWS region
const REGION = "us-east-2"; // The AWS Region. For example, "us-east-1".
var fs = require("fs");
var res;
var imagedata = fs.readFileSync('./1.png')
res = imagedata.toString('base64')
console.log("res2")
console.log(typeof(res))
// console.log(res)
const client = new TextractClient({ region: REGION });
const params = {
  Document : {
    Bytes: res
  }
}
console.log("params")
console.log(typeof(params))
// console.log(params)
const command = new AnalyzeDocumentCommand(params);
console.log("command")
console.log(typeof(command))
const run = async () => {
  // async/await.
  try {
    const data = await client.send(command);
    console.log(data)
    // process data.
  } catch (error) {
    console.log("Error");
    console.log(error)
    // error handling.
  } finally {
    // finally.
  }
};
run()