亚马逊 S3 &校验和 [英] Amazon S3 & Checksum

查看:46
本文介绍了亚马逊 S3 &校验和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试验证上传到存储桶的文件的完整性,但我没有找到任何相关信息.

I try to verify the integrity of a file that was uploaded to a bucket but I don't find any information of this.

在文件的标题中,有一个E-tag",但我认为它不是 md5 校验和.

In the file's headers, there is a "E-tag" but I think its not a md5 checksum.

那么,如何检查我在 Amazon S3 上上传的文件是否与我在计算机上的文件相同?

So, how can I check if the file that I uploaded on Amazon S3 is the same that I have on my computer ?

谢谢.:)

推荐答案

如果您使用 REST API 在单个操作中上传对象(最多 5GB),那么您可以添加 Content-MD5<PUT 请求中的/strong> 标头.根据 PUT 的 S3 文档,Content-MD5 标头是:

If you are using the REST API to upload an object (up to 5GB) in a single operation, then you can add the Content-MD5 header in your PUT request. According the the S3 documentation for PUT, the Content-MD5 header is:

根据 RFC 1864 消息的 base64 编码的 128 位 MD5 摘要(不带标头).此标头可用作消息完整性检查以验证数据是否相同那是最初发送的.虽然它是可选的,但我们建议使用 Content-MD5 机制作为端到端的完整性检查.

The base64 encoded 128-bit MD5 digest of the message (without the headers) according to RFC 1864. This header can be used as a message integrity check to verify that the data is the same data that was originally sent. Although it is optional, we recommend using the Content-MD5 mechanism as an end-to-end integrity check.

检查这个答案关于如何计算一个 base64 编码的 128 位 MD5 摘要.如果您使用 s3curl,您可以使用 --contentMd5 选项.

Check this answer on how to compute a base64 encoded 128-bit MD5 digest. If you are using s3curl, you can include the computed digest in your request headers using the --contentMd5 option.

如果亚马逊在上传完成时计算的 md5 摘要与您在 Content-MD5 标头中提供的 md5 摘要不匹配,亚马逊将使用 BadDigest 错误代码进行响应.

If the md5 digest computed by Amazon upon upload completion does not match the md5 digest you provided in the Content-MD5 header, Amazon will respond with a BadDigest error code.

如果您使用分段上传,则 Content-MD5 标头可单独对每个部分进行完整性检查.分段上传完成后,亚马逊目前不提供验证组合文件完整性的方法.

If you are using multipart upload, the Content-MD5 header serves as an integrity check for each part individually. Once the multipart upload is finalized, Amazon does not currently provide a way to verify the integrity of the assembled file.

这篇关于亚马逊 S3 &amp;校验和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆