English 中文(简体)
亚马孙 S3, 如何处理从上载到目标供应的延误
原标题:Amazon S3, how to deal with the delay from Upload to Object availability

大约一米大楼允许用户上载一个档案。 档案上载到亚马孙3号私人桶。

然后,用户可以下载文件,我们可以通过设定一个过期的URL:

AWS::S3::S3Object.url_for(attachment.path(style || attachment.default_style), attachment.bucket_name, :expires_in => expires_in, :use_ssl => true)

我们回头的问题是,从高载到通过AWS:S3:S3Object.url_for。 如果用户在上载后试图下载档案,亚马孙的错误如下:

215412-NameError (uninitialized constant Attachment::AWS):
215413-  app/models/attachment.rb:32:in `authenticated_url 
215414-  app/controllers/attachments_controller.rb:33:in `show 

Any ideas on how to optimize, deal with this delay?

Thanks

问题回答

I know it s been years, but for those who came here with the same issue, here is what I ve found.

首先,它只是“https://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html#ConsistencyModel”rel=“noreferer”。 AWS S3 Engineering :

一项程序写给亚马孙S3的新物品,并立即在其桶内列出钥匙。 在全面宣传改变之前,该物体可能不会出现在名单上。

我发现处理这种行为的最佳方式是等待一个上载物体出现在清单中,然后让用户下载。

类似:

_put_object(filename)
while True:
    if _file_exists(filename):
        break
    time.sleep(1)

To check availability we can use client.head_object or client.list_objects_v2.

There is an opinion that list_objects_v2 works faster

你看到的拖延时间多长? 经常发生这种情况?

We upload directly to s3 from the browser using https://github.com/PRX/s3-swf-upload-plugin , and by the time I get a callback that the file exists, I have never seen an error with it being not yet available.

Another thing we do is to mark the object to one state on first upload, then use an asycnh process to validate the file, and only after it is marked valid do we go ahead and process it. This causes a delay however, so it may not be such a great answer for you.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签