无法将“Body”转换为字符串S3.InvalidContent arn:aws:states:::aws-sdk:s3:getObject步骤函数。

0

【以下的问题经过翻译处理】 我正在编写一个非常简单的 step function 状态机,使用AWS SDK从S3中检索文件。

每次运行时,从S3获取文件的任务都会失败,并显示一个"S3.InvalidContent"错误,"Failed to convert 'Body' to string"是原因。

我的状态机的完整定义如下:

{
  "Comment": "A description of my state machine",
  "StartAt": "GetAudioFile",
  "States": {
    "GetAudioFile": {
      "Type": "Task",
      "Parameters": {
        "Bucket": "11123",
        "Key": "test.wav"
      },
      "Resource": "arn:aws:states:::aws-sdk:s3:getObject",
      "End": true
    }
  }
}

TaskFailed事件的完整文本是:

{
  "resourceType": "aws-sdk:s3",
  "resource": "getObject",
  "error": "S3.InvalidContent",
  "cause": "Failed to convert 'Body' to string"
}

具有错误的CloudWatch日志条目的完整文本如下:

{
    "id": "5",
    "type": "TaskFailed",
    "details": {
        "cause": "Failed to convert 'Body' to string",
        "error": "S3.InvalidContent",
        "resource": "getObject",
        "resourceType": "aws-sdk:s3"
    },
    "previous_event_id": "4",
    "event_timestamp": "1651894187569",
    "execution_arn": "arn:aws:states:us-east-1:601423303632:execution:test:44ae6102-b544-3cfa-e186-181cdf331493"
}
  1. 我做错了什么?
  2. 我该如何解决?
  3. 您还需要哪些其他信息?
  4. 最重要的是,我在哪里可以找到答案来回答这些问题?
profile picture
전문가
질문됨 6달 전17회 조회
1개 답변
0

【以下的回答经过翻译处理】 Step Function需要API调用的响应能够序列化为JSON。如果您在S3中有包含该数据的文件,则会在响应负载中返回该文件,并且该文件将被用作任务的状态输出(在输出处理后)。在这种情况下,您的文件是一个二进制.wav文件,不可行。有关步骤函数开发人员指南中状态机数据的更多信息,请参见以下链接:https://docs.aws.amazon.com/step-functions/latest/dg/concepts-state-machine-data.html

鉴于此,我很好奇您的工作流程中涉及到 .wav 文件的目的是什么?开发人员通常使用Step Function来管理此类数据,但使用的是工作流程中的 "指针"(即 S3 键),而不是将数据加载到工作流程状态中。

profile picture
전문가
답변함 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠