我想使用对象的 sha256 和作为 etag。我正在使用以下代码来尝试指定 etag:
aws s3 cp foo-lambda.zip s3://foo-bucket/lambda-code/foo-lambda/foo-lambda.zip --metadata ETag=FkyOB6C4wZQz5w9ClCMKxnK8A0iqCk4RWSO0Epbbc4I= --profile foo-profile
此操作成功,没有错误消息或警告。但是,AWS S3控制台中的etag与该值不匹配;相反,它是 zip 的 MD5 和。我尝试删除该对象并再次上传,结果相同。
编辑:这是来自命令行的更多信息
aws s3api head-object --bucket foo-bucket --key lambda-code/foo-lambda/foo-lambda.zip --profile foo-profile
回应
{
"AcceptRanges": "bytes",
"ContentType": "application/zip",
"LastModified": "Mon, 01 May 2017 18:17:11 GMT",
"ContentLength": 584,
"ETag": "\"729439461018d55c885e56b858e54676\"",
"Metadata": {
"etag": "FkyOB6C4wZQz5w9ClCMKxnK8A0iqCk4RWSO0Epbbc4I="
}
}
因此请注意,ETag
值是错误的,但 Metadata.etag
值是我想要的值。
最佳答案
Amazon 使用 etag 来执行系统中的各种任务。您必须继续使用您在问题中建议的元数据。
ETag
The entity tag is a hash of the object. The ETag reflects changes only to the contents of an object, not its metadata. The ETag may or may not be an MD5 digest of the object data. Whether or not it is depends on how the object was created and how it is encrypted as described below:
- Objects created by the PUT Object, POST Object, or Copy operation, or through the AWS Management Console, and are encrypted by SSE-S3 or plaintext, have ETags that are an MD5 digest of their object data.
- Objects created by the PUT Object, POST Object, or Copy operation, or through the AWS Management Console, and are encrypted by SSE-C or SSE-KMS, have ETags that are not an MD5 digest of their object data.
- If an object is created by either the Multipart Upload or Part Copy operation, the ETag is not an MD5 digest, regardless of the method of encryption.
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html
关于amazon-web-services - AWS S3指定etag值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43724240/