S3 putObject“expires”如何工作?(How S3 putObject “expires” works?)
来自AWS SDK for PHP的 S3的
putObject
方法声明我可以传递指定的Expires
参数对象不再可缓存的日期和时间。
我很困惑......它究竟意味着什么?
我认为对象的存储桶,密钥和URL永远保持不变。
S3's
putObject
method from AWS SDK for PHP states that I can pass aExpires
parameter that specifiesThe date and time at which the object is no longer cacheable.
I'm confused by that... what does it mean exactly?
I thought that the object's bucket, key and URL stays the same forever.
原文:
最满意答案
该文档似乎表明这种确切的行为是通过设计的:
:shallow - 如果为true,则引用特定成员(即带有:id参数的成员)的嵌套资源的路径不会使用父路径前缀或名称前缀。
(来自http://api.rubyonrails.org/classes/ActionController/Resources.html#M000501 )
由于使用:shallow选项会导致您的:path_prefix在某些情况下被忽略,如果您必须始终使用此前缀,则应考虑删除:shallow选项。 这是一个替代解决方案,似乎可以满足您的需求:
map.with_options :path_prefix => "blog" do |blog| blog.resources :posts do |posts| posts.resources :comments, :only => [:index, :create, :new] end blog.resources :comments, :except => [:index, :create, :new] end
导致这些路线:
# posts GET /blog/posts {:controller=>"posts", :action=>"index"} # POST /blog/posts {:controller=>"posts", :action=>"create"} # new_post GET /blog/posts/new {:controller=>"posts", :action=>"new"} # edit_post GET /blog/posts/:id/edit {:controller=>"posts", :action=>"edit"} # post GET /blog/posts/:id {:controller=>"posts", :action=>"show"} # PUT /blog/posts/:id {:controller=>"posts", :action=>"update"} # DELETE /blog/posts/:id {:controller=>"posts", :action=>"destroy"} # post_comments GET /blog/posts/:post_id/comments {:controller=>"comments", :action=>"index"} # POST /blog/posts/:post_id/comments {:controller=>"comments", :action=>"create"} # new_post_comment GET /blog/posts/:post_id/comments/new {:controller=>"comments", :action=>"new"} # edit_comment GET /blog/comments/:id/edit {:controller=>"comments", :action=>"edit"} # comment GET /blog/comments/:id {:controller=>"comments", :action=>"show"} # PUT /blog/comments/:id {:controller=>"comments", :action=>"update"} # DELETE /blog/comments/:id {:controller=>"comments", :action=>"destroy"}
希望这可以帮助!
the documentation seems to indicate this exact behavior is by design:
:shallow - If true, paths for nested resources which reference a specific member (ie. those with an :id parameter) will not use the parent path prefix or name prefix.
(from http://api.rubyonrails.org/classes/ActionController/Resources.html#M000501)
Since using the :shallow option will cause your :path_prefix to be ignored in some cases, if you must always have this prefix you should consider removing the :shallow option. Here's an alternate solution that appears to do what you need:
map.with_options :path_prefix => "blog" do |blog| blog.resources :posts do |posts| posts.resources :comments, :only => [:index, :create, :new] end blog.resources :comments, :except => [:index, :create, :new] end
Resulting in these routes:
# posts GET /blog/posts {:controller=>"posts", :action=>"index"} # POST /blog/posts {:controller=>"posts", :action=>"create"} # new_post GET /blog/posts/new {:controller=>"posts", :action=>"new"} # edit_post GET /blog/posts/:id/edit {:controller=>"posts", :action=>"edit"} # post GET /blog/posts/:id {:controller=>"posts", :action=>"show"} # PUT /blog/posts/:id {:controller=>"posts", :action=>"update"} # DELETE /blog/posts/:id {:controller=>"posts", :action=>"destroy"} # post_comments GET /blog/posts/:post_id/comments {:controller=>"comments", :action=>"index"} # POST /blog/posts/:post_id/comments {:controller=>"comments", :action=>"create"} # new_post_comment GET /blog/posts/:post_id/comments/new {:controller=>"comments", :action=>"new"} # edit_comment GET /blog/comments/:id/edit {:controller=>"comments", :action=>"edit"} # comment GET /blog/comments/:id {:controller=>"comments", :action=>"show"} # PUT /blog/comments/:id {:controller=>"comments", :action=>"update"} # DELETE /blog/comments/:id {:controller=>"comments", :action=>"destroy"}
Hope this helps!
相关问答
更多-
在选项哈希中传递路径,而不是第一个参数: <%= simple_form_for :booth, :url => hall_booths_path(@hall) do |f| %> ... <% end %> 请注意, hall_booths_path的参数是Hall ,而不是Booth 。 创建子项时,需要提供父项。 另一种选择是不传递URL而是传递模型对象。 假设@hall是现有的Hall而@booth是一个新的Booth : <%= simple_form_for [@hall, @boot ...
-
将默认值添加到由* _path方法生成的路由的前缀中(Add default value into prefix to my routes generated by the *_path methods)[2022-08-14]
您应该覆盖应用程序控制器中的default_url_options 。 class ApplicationController > ActionController::Base # ... def default_url_options(options) { :company => current_company.id } end end You should overwrite the default_url_options in your application contro ... -
Scoped Omniauth路线(Scoped Omniauth routes)[2023-10-16]
我们能够使用以下omniauth初始化程序(包括google openid提供程序的配置)完成此操作,尽管相同的概念可能适用于其他提供程序): require "openid/store/filesystem" Rails.application.config.middleware.use OmniAuth::Builder do AUTH_REGEX = /^\/([^\/]+)\/auth\/([^\/]+)$/ CALLBACK_REGEX = /^\/([^\/]+)\/auth\/([^ ... -
前缀param rails routes(prefix param rails routes)[2022-10-12]
尝试 class ApplicationController < ActionController::Base def user_path(user) super(:param_for_route_name_spacing, user) end end try class ApplicationController < ActionController::Base def user_path(user) super(:param_for_route_name_spacing, ... -
Ember Routes如何?(Ember Routes How To?)[2021-09-11]
我看到三种方法: 将它放在books资源下并要求作者作为路由参数: this.resource('books', function() { this.route('new', { path: '/new/:author_id' }); }); 将路径放在books资源下,但将作者放在查询参数中 。 this.resource('books', function() { // Declare required query parameter on controller for `new` r ... -
当您到达应用程序中的第一个URL(root_url,users_url ...)时,在您进入set_locale之前,URL将显示在您的Web浏览器中。 然后,如果您访问应用程序中的其他链接,则会在URL中添加区域设置。 但是翻译仍然适用于您在I18n.locale设置的语言环境。 When you arrive on any url for the first on the application (root_url, users_url ...) the url is displayed in your ...
-
命名空间内的浅路由:path param不起作用(Shallow routes inside a namespace with :path param not working)[2022-02-06]
您需要指定shallow_path : namespace :api, path: nil, shallow_path: nil, except: [:new, :edit] do resources :blogs, shallow: true do resources :comments end end 给你这个: Prefix Verb URI Pattern Controller#Action blog_comments ... -
有没有更好的方法在Rails 3路由中使用with_options?(Is there a better way to do with_options in Rails 3 routes?)[2023-02-27]
是的, with_options仍然适用于Rails 3.试试这个: map.with_options :controller => 'foo', :via => :post do match 'one', :action => 'one' #automatically generates one_* helpers match 'two', :action => 'two' #automatically generates two_* helpers foo.with_options :sp ... -
如何删除routes.rb中为路径中的参数生成的前缀(How to remove the prefix generated in routes.rb for the params in the path)[2024-01-09]
你可以这样做: resources :users do member do get 'account_setting' end end 要添加成员路由,请将成员块添加到资源块中。 有关文档,您可以查看http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html You can do it as follows: resources :users do ... -
该文档似乎表明这种确切的行为是通过设计的: :shallow - 如果为true,则引用特定成员(即带有:id参数的成员)的嵌套资源的路径不会使用父路径前缀或名称前缀。 (来自http://api.rubyonrails.org/classes/ActionController/Resources.html#M000501 ) 由于使用:shallow选项会导致您的:path_prefix在某些情况下被忽略,如果您必须始终使用此前缀,则应考虑删除:shallow选项。 这是一个替代解决方案,似乎可以满足您的 ...