lib/carrierwave/storage/aliyun.rb in carrierwave-aliyun-0.3.2 vs lib/carrierwave/storage/aliyun.rb in carrierwave-aliyun-0.3.3

- old
+ new

@@ -13,18 +13,21 @@ def initialize(options={}) @aliyun_access_id = options[:aliyun_access_id] @aliyun_access_key = options[:aliyun_access_key] @aliyun_bucket = options[:aliyun_bucket] @aliyun_area = options[:aliyun_area] || 'cn-hangzhou' + @aliyun_upload_host = options[:aliyun_upload_host] # Host for upload - if options[:aliyun_internal] == true - @aliyun_upload_host = "http://#{@aliyun_bucket}.oss-#{@aliyun_area}-internal.aliyuncs.com" - else - @aliyun_upload_host = "http://#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com" + if @aliyun_upload_host.nil? + if options[:aliyun_internal] == true + @aliyun_upload_host = "http://#{@aliyun_bucket}.oss-#{@aliyun_area}-internal.aliyuncs.com" + else + @aliyun_upload_host = "http://#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com" + end end - + # Host for get request @aliyun_host = options[:aliyun_host] || "http://#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com" if not @aliyun_host.include?("http") raise "config.aliyun_host requirement include http:// or https://, but you give: #{@aliyun_host}" @@ -214,10 +217,11 @@ :aliyun_access_id => @uploader.aliyun_access_id, :aliyun_access_key => @uploader.aliyun_access_key, :aliyun_area => @uploader.aliyun_area, :aliyun_bucket => @uploader.aliyun_bucket, :aliyun_internal => @uploader.aliyun_internal, - :aliyun_host => @uploader.aliyun_host + :aliyun_host => @uploader.aliyun_host, + :aliyun_upload_host => @uploader.aliyun_upload_host } @oss_connection ||= CarrierWave::Storage::Aliyun::Connection.new(config) end end