Amazon S3:客户端可以在上传完成之前看到文件吗 [英] Amazon S3: Can clients see the file before upload is complete

查看:117
本文介绍了Amazon S3:客户端可以在上传完成之前看到文件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html ,我发现了以下内容:

Amazon S3从未添加部分对象;如果您收到成功响应,则Amazon S3将整个对象添加到存储桶中.

但这是关于收到成功回复的话题.我是否保证在列出存储桶中的对象时,没有 other 客户端会看到该对象-直到整个对象都上传了?

我想将S3用作假脱机"目录-我将在那里上传文件,另一个客户端将定期列出文件,然后下载它们.我不希望它尝试下载未完全上传的文件.

解决方案

答案与此相同:

Amazon S3从未添加部分对象

在上传完成之前,从技术上讲,正在上传的内容不在存储桶中.

您可能知道,

S3不是分层文件系统.它具有至少两个重要的组件,即后备存储区和索引,这与典型的文件系统不同,它们是分开的……因此,当您编写对象时,实际上并没有就地"编写它.上载对象会将对象保存到后备存储中,然后然后将其添加到存储桶的索引中,GET和其他请求将使用该索引来获取存储的数据和元数据以进行检索.

索引中没有任何条目,则无法访问该对象.所以你很好.无法下载尚未完成上传的对象.从技术上讲,该对象尚不存在.

类似地,如果一个对象已经存在并且您开始覆盖它,那么任何尝试下载它的人至少都会获得该对象的旧"副本,直到您的上传完成为止,即使在未启用版本控制的存储桶中也是如此. -覆盖不会覆盖实际的对象,它会覆盖索引条目,并且仅在上载完成时才会发生.请注意,此机制似乎是适用于最终一致性模型的原因,该模型适用于覆盖现有对象的PUT请求.


注意,关于数据完整性:确保使用的任何上传都设置Content-MD请求标头.通过为S3提供一种机制来检测传输错误并在上传的内容不匹配时强制失败,从而防止了上传损坏.

At http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html, I found the following:

Amazon S3 never adds partial objects; if you receive a success response, Amazon S3 added the entire object to the bucket.

But that's talking about me receiving a success response. Am I guaranteed that no other client will see the object when listing objects in the bucket -- until the entire object is uploaded?

I want to use S3 as a "spool" directory -- I'll upload files there, and another client will periodically list the files and then download them. I don't want it attempting to download a file that's not completely uploaded.

解决方案

The answer is along the same line as this:

Amazon S3 never adds partial objects

Until an upload completes, the content that was being uploaded is not technically "in" the bucket.

S3, as you likely know, is not a hierarchical filesystem. It has at least two significant components, the backing store and the index which, unlike in a typical filesystem, are separate... so when you're writing an object, you're not really writing it "in place." Uploading an object saves the object to the backing store, and then adds it to the bucket's index, which is used by GET and other requests to fetch the stored data and metadata for retrieval.

With no entry in the index, the object is not accessible. So you're good. Downloading an object that hasn't finished uploading yet is impossible. The object, technically, doesn't yet exist.

Similarly, if an object already exists and you start overwriting it, anyone attempting to download it would get the "old" copy of the object at least until your upload has finished, and this is true even in a bucket without versioning enabled -- overwriting doesn't overwrite the actual object, it overwrites the index entry, and this only happens when the upload is complete. Note that this mechanism appears to be responsible for the eventual consistency model that applies to PUT requests that overwrite existing objects.


Note, with regard to data integrity: be sure that whatever you are using upload sets the Content-MD request header. This prevents a corrupted upload by giving S3 a mechanism to detect transmission errors and force a failure if the content being uploaded doesn't match.

这篇关于Amazon S3:客户端可以在上传完成之前看到文件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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