如何在 AWSJavaScriptSDK 中以 200 OK 结果捕获失败的 S3 copyObject

How to catch failed S3 copyObject with 200 OK result in AWSJavaScriptSDK

AWSJavaScriptSDK 中 S3.copyObject 方法的

Documentation 表示如下:

A copy request might return an error when Amazon S3 receives the copy request or while Amazon S3 is copying the files. If the error occurs before the copy operation starts, you receive a standard Amazon S3 error. If the error occurs during the copy operation, the error response is embedded in the 200 OK response. This means that a 200 OK response can contain either a success or an error. Design your application to parse the contents of the response and handle it appropriately.

但是,没有给出失败可能是什么样子的示例,并且 aws-sdk 节点库中与 copyObject 关联的类型(即 CopyObjectResult 和 S3.Types.CopyObjectOutput)表明不存在在成功响应中报告失败副本的位置。

有谁知道如何解读这份文件吗?向 copyObject 返回 200 OK 时复制操作失败的示例是什么,调用者如何知道?

SDK 本身将 200 个状态 OK 响应转化为特定 API 调用的错误,包括 copyObject。

this commit , the operations completeMultipartUpload, copyObject, and uploadPartCopy are flagged as able to return a status code 200 that is actually an error, and there is a handler 开始将这些响应强制转换为错误响应。