Amazon S3: Can clients see the file before upload is complete

拈花ヽ惹草 提交于 2020-08-01 10:51:08

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/38173710/amazon-s3-can-clients-see-the-file-before-upload-is-complete

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!