amazon-web-services - AWS S3指定etag值

标签 amazon-web-services amazon-s3

我想使用对象的 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/

相关文章:

amazon-web-services - 如何获取 Amazon EC2 Spot 实例中断率

amazon-web-services - 在 AWS Step Functions 中传递变量

amazon-web-services - AWS 无服务器图像处理程序 - Lambda 错误

ruby-on-rails - 亚马逊 s3 - ruby 。获取刚刚上传的资源的URL

Hadoop:AWS EMR 作业中的输入和输出路径

amazon-web-services - 如何通过 API Gateway 调用 AWS Step Functions?

Laravel Aws\Laravel\AwsServiceProvider::class 未找到

amazon-web-services - 自动接受来自另一个 AWS 账户的 Transit Gateway 附件

angularjs - EC2 或 S3 来托管 AngularJS 应用程序?

ssl - 通过 Stripe Checkout 使用 AWS Lambda、S3 和 Cloudfront 支付的 CORS 问题