用 ListParts() 结果填充 CompleteMultipartUpload() 部件列表是否安全?

Is it safe to fill CompleteMultipartUpload() parts list with ListParts() result?

CompleteMultipartUpload API我们必须把上传的零件列表放在电子标签上。

我看到 ListParts 结果与我的应用程序关于部件的状态不同。我的所有 UploadPart 调用都没有任何错误,但有时 ListParts 会遗漏其中一些。

那么,用ListPartsAPI的结果来填充这些E-tags对吗?如果不是,为什么结果不一样?

调用CompleteMultipartUpload时使用ListParts响应数据不安全。这样做可以掩盖代码中的问题。

Only use the returned listing for verification. You should not use the result of this listing when sending a complete multipart upload request. Instead, maintain your own list of the part numbers you specified when uploading parts and the corresponding ETag values that Amazon S3 returns.

https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html

ListParts 仅用于完整性检查,以供比较。您需要使用上传原始部分时收到的 etags。如果 ListParts 响应不完整,那可能只是 S3 中的最终一致性问题,后续轮询可能 return 明显缺失的部分。如果 ListParts 响应实际上与您在上传部分时收到的内容有冲突,则说明您的代码存在问题或在线路上或 S3 内部(不太可能)损坏。

分段上传客户端不需要 ListParts 操作。