tencent cloud

文档反馈

图片处理回调

最后更新时间:2022-08-11 15:17:16

    功能说明

    数据万象支持自定义设置回调 URL,在任务完成后,系统向该 URL 发送 HTTP POST 请求,请求体中包含通知内容。您可通过配置的回调地址及时了解任务处理的进展和状态,以便进行其他业务操作。

    回调内容

    任务完成后,系统会向您设置的回调地址发送回调内容,该响应体返回为 application/xml 数据,包含完整节点数据的内容展示如下:

    <Response>
      <EventName>TaskFinish</EventName>
      <JobsDetail>
          <Code>Success</Code>
          <CreationTime>2022-07-18T15:16:43+0800</CreationTime>
          <EndTime>2022-07-18T15:16:44+0800</EndTime>
          <Input>
              <BucketId>test-1234567890</BucketId>
              <Object>input/deer.jpg</Object>
              <Region>ap-chongqing</Region>
          </Input>
          <JobId>c93984788066911ed89ed352d4d9d2084</JobId>
          <Message/>
          <Operation>
              <Output>
                  <Bucket>test-1234567890</Bucket>
                  <Object>output/out.jpg</Object>
                  <Region>ap-chongqing</Region>
              </Output>
              <PicProcessResult>
                  <ObjectName>output/out.jpg</ObjectName>
                  <OriginalInfo>
                      <Etag>"d5a491cd3d8d071e3212c3478e8e35a1"</Etag>
                      <ImageInfo>
                          <Ave>0xc64847</Ave>
                          <Format>JPEG</Format>
                          <Height>417</Height>
                          <Orientation>0</Orientation>
                          <Quality>68</Quality>
                          <Width>500</Width>
                      </ImageInfo>
                  </OriginalInfo>
                  <ProcessResult>
                      <Etag/>
                      <Format>JPEG</Format>
                      <Height>500</Height>
                      <Quality>68</Quality>
                      <Size>24911</Size>
                      <Width>417</Width>
                  </ProcessResult>
              </PicProcessResult>
              <TemplateId>t10461fe2bd5a649db9022452ec71e0381</TemplateId>
              <TemplateName>test</TemplateName>
              <UserData>This is my PicProcess job.</UserData>
          </Operation>
          <QueueId>p2911917386e148639319e13c285cc774</QueueId>
          <StartTime>2022-07-18T15:16:44+0800</StartTime>
          <State>Success</State>
          <Tag>PicProcess</Tag>
      </JobsDetail>
    </Response>
    

    具体的数据内容如下:

    节点名称(关键字) 父节点 描述 类型
    Response 保存结果的容器 Container

    Container 节点 Response 的内容:

    节点名称(关键字) 父节点 描述 类型
    EventName Response 固定值,为 TaskFinish String
    JobsDetail Response 任务的详细信息 Container

    Container 节点 JobsDetail 的内容:同提交图片处理任务接口中的 Response.JobsDetail

    如果任务是通过工作流触发的,Response.JobsDetail.Input 还会包含 CosHeaders 节点,类型为 Container 数组。

    Container 节点 CosHeaders 的内容:

    节点名称(关键字) 父节点 描述 类型
    Key Response.JobsDetail.Input.CosHeaders 自定义 Header 的名称 String
    Value Response.JobsDetail.Input.CosHeaders 自定义 Header 的值 String

    如果任务是通过工作流触发的,Response.JobsDetail 还会包含 Workflow 节点,类型为 Container。

    Container 节点 Workflow 的内容:

    节点名称(关键字) 父节点 描述 类型
    RunId Response.Workflow 工作流实例 ID String
    WorkflowId Response.Workflow 工作流 ID String
    WorkflowName Response.Workflow 工作流名称 String
    Name Response.Workflow 工作流节点名称 String

    实际案例

    案例 1:通过任务接口触发的任务回调

    <Response>
      <EventName>TaskFinish</EventName>
      <JobsDetail>
          <Code>Success</Code>
          <CreationTime>2022-07-18T15:16:43+0800</CreationTime>
          <EndTime>2022-07-18T15:16:44+0800</EndTime>
          <Input>
              <BucketId>test-1234567890</BucketId>
              <Object>input/deer.jpg</Object>
              <Region>ap-chongqing</Region>
          </Input>
          <JobId>c93984788066911ed89ed352d4d9d2084</JobId>
          <Message/>
          <Operation>
              <Output>
                  <Bucket>test-1234567890</Bucket>
                  <Object>output/out.jpg</Object>
                  <Region>ap-chongqing</Region>
              </Output>
              <PicProcessResult>
                  <ObjectName>output/out.jpg</ObjectName>
                  <OriginalInfo>
                      <Etag>"d5a491cd3d8d071e3212c3478e8e35a1"</Etag>
                      <ImageInfo>
                          <Ave>0xc64847</Ave>
                          <Format>JPEG</Format>
                          <Height>417</Height>
                          <Orientation>0</Orientation>
                          <Quality>68</Quality>
                          <Width>500</Width>
                      </ImageInfo>
                  </OriginalInfo>
                  <ProcessResult>
                      <Etag/>
                      <Format>JPEG</Format>
                      <Height>500</Height>
                      <Quality>68</Quality>
                      <Size>24911</Size>
                      <Width>417</Width>
                  </ProcessResult>
              </PicProcessResult>
              <TemplateId>t10461fe2bd5a649db9022452ec71e0381</TemplateId>
              <TemplateName>test</TemplateName>
              <UserData>This is my PicProcess job.</UserData>
          </Operation>
          <QueueId>p2911917386e148639319e13c285cc774</QueueId>
          <StartTime>2022-07-18T15:16:44+0800</StartTime>
          <State>Success</State>
          <Tag>PicProcess</Tag>
      </JobsDetail>
    </Response>
    

    案例 2:通过工作流触发的任务回调

    <Response>
      <EventName>TaskFinish</EventName>
      <JobsDetail>
          <Code>Success</Code>
          <CreationTime>2022-07-18T15:16:43+0800</CreationTime>
          <EndTime>2022-07-18T15:16:44+0800</EndTime>
          <Input>
              <BucketId>test-1234567890</BucketId>
              <Object>input/deer.jpg</Object>
              <Region>ap-chongqing</Region>
              <CosHeaders>
                  <Key>Content-Type</Key>
                  <Value>image/jpeg</Value>
              </CosHeaders>
              <CosHeaders>
                  <Key>x-cos-request-id</Key>
                  <Value>NjJiZDYwYTFfNjUzYTYyNjRfZjEwZl8xMmZhYzY5</Value>
              </CosHeaders>
              <CosHeaders>
                  <Key>EventName</Key>
                  <Value>cos:ObjectCreated:Put</Value>
              </CosHeaders>
              <CosHeaders>
                  <Key>Size</Key>
                  <Value>1024</Value>
              </CosHeaders>
          </Input>
          <JobId>c93984788066911ed89ed352d4d9d2084</JobId>
          <Message/>
          <Operation>
              <Output>
                  <Bucket>test-1234567890</Bucket>
                  <Object>output/out.jpg</Object>
                  <Region>ap-chongqing</Region>
              </Output>
              <PicProcessResult>
                  <ObjectName>output/out.jpg</ObjectName>
                  <OriginalInfo>
                      <Etag>"d5a491cd3d8d071e3212c3478e8e35a1"</Etag>
                      <ImageInfo>
                          <Ave>0xc64847</Ave>
                          <Format>JPEG</Format>
                          <Height>417</Height>
                          <Orientation>0</Orientation>
                          <Quality>68</Quality>
                          <Width>500</Width>
                      </ImageInfo>
                  </OriginalInfo>
                  <ProcessResult>
                      <Etag/>
                      <Format>JPEG</Format>
                      <Height>500</Height>
                      <Quality>68</Quality>
                      <Size>24911</Size>
                      <Width>417</Width>
                  </ProcessResult>
              </PicProcessResult>
              <TemplateId>t10461fe2bd5a649db9022452ec71e0381</TemplateId>
              <TemplateName>test</TemplateName>
              <UserData>This is my PicProcess job.</UserData>
          </Operation>
          <QueueId>p2911917386e148639319e13c285cc774</QueueId>
          <StartTime>2022-07-18T15:16:44+0800</StartTime>
          <State>Success</State>
          <Tag>PicProcess</Tag>
          <Workflow>
              <Name>PicProcess_1581665960537</Name>
              <RunId>ic90edd59f84f11ec9d4f525400a3c59f</RunId>
              <WorkflowId>web6ac56c1ef54dbfa44d7f4103203be9</WorkflowId>
              <WorkflowName>workflow-test</WorkflowName>
          </Workflow>
      </JobsDetail>
    </Response>
    

    案例 3:通过工作流触发的任务回调, 格式为 JSON

    {
    "EventName": "TaskFinish",
    "JobsDetail": {
    "Code": "Success",
    "CreationTime": "2022-07-18T15:16:43+0800",
    "EndTime": "2022-07-18T15:16:44+0800",
    "Input": {
        "BucketId": "test-1234567890",
        "Object": "input/deer.jpg",
        "Region": "ap-chongqing",
        "CosHeaders": [{
                "Key": "Content-Type",
                "Value": "image/jpeg"
            },
            {
                "Key": "x-cos-request-id",
                "Value": "NjJiZDYwYTFfNjUzYTYyNjRfZjEwZl8xMmZhYzY5"
            },
            {
                "Key": "EventName",
                "Value": "cos:ObjectCreated:Put"
            },
            {
                "Key": "Size",
                "Value": "1024"
            }
        ]
    },
    "JobId": "c93984788066911ed89ed352d4d9d2084",
    "Operation": {
        "Output": {
            "Bucket": "test-1234567890",
            "Object": "output/out.jpg",
            "Region": "ap-chongqing"
        },
        "PicProcessResult": {
            "ObjectName": "output/out.jpg",
            "OriginalInfo": {
                "Etag": "\"d5a491cd3d8d071e3212c3478e8e35a1\"",
                "ImageInfo": {
                    "Ave": "0xc64847",
                    "Format": "JPEG",
                    "Height": "417",
                    "Orientation": "0",
                    "Quality": "68",
                    "Width": "500"
                }
            },
            "ProcessResult": {
                "Format": "JPEG",
                "Height": "500",
                "Quality": "68",
                "Size": "24911",
                "Width": "417"
            }
        },
        "TemplateId": "t10461fe2bd5a649db9022452ec71e0381",
        "TemplateName": "test",
        "UserData": "This is my PicProcess job."
    },
    "QueueId": "p2911917386e148639319e13c285cc774",
    "StartTime": "2022-07-18T15:16:44+0800",
    "State": "Success",
    "Tag": "PicProcess",
    "Workflow": {
        "Name": "PicProcess_1581665960537",
        "RunId": "ic90edd59f84f11ec9d4f525400a3c59f",
        "WorkflowId": "web6ac56c1ef54dbfa44d7f4103203be9",
        "WorkflowName": "workflow-test"
    }
    }
    }
    
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持