Permalink
Browse files

Update lib/carrierwave/storage/upyun.rb

解决 “改进 Upyun 初始化,减少连接的过程” 中bucket混乱的问题
属于issue #16
  • Loading branch information...
1 parent 39f37af commit 48448909c7eaf4ee21577be438bc7a22de2adcc1 @vvdpzz vvdpzz committed Nov 23, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/carrierwave/storage/upyun.rb
@@ -30,9 +30,12 @@ def initialize(options={})
@upyun_bucket = options[:upyun_bucket]
@connection_options = options[:connection_options] || {}
@host = options[:api_host] || 'http://v0.api.upyun.com'
- @@http ||= RestClient::Resource.new("#{@host}/#{@upyun_bucket}",
- :user => @upyun_username,
- :password => @upyun_password)
+ @@http ||= new_rest_client
+ @@http = new_rest_client if @@http.url != "#{@host}/#{@upyun_bucket}"
+ end
+
+ def new_rest_client
+ RestClient::Resource.new("#{@host}/#{@upyun_bucket}", :user => @upyun_username, :password => @upyun_password)
end
def put(path, payload, headers = {})

0 comments on commit 4844890

Please sign in to comment.