Commit 665e8850 by liubin

upgrade to new version of Ruby SDK

parent b5005154
......@@ -5,9 +5,9 @@ module Paperclip
module Qiniu
def self.extended base
begin
require 'qiniu-rs'
require 'qiniu'
rescue LoadError => e
e.message << " (You may need to install the qiniu-rs gem)"
e.message << " (You may need to install the qiniu gem)"
raise e
end unless defined?(::Qiniu)
......@@ -25,7 +25,7 @@ module Paperclip
def exists?(style = default_style)
init
!!::Qiniu::RS.stat(bucket, path(style))
!!::Qiniu.stat(bucket, path(style))
end
def flush_writes
......@@ -48,7 +48,7 @@ module Paperclip
def flush_deletes
init
for path in @queued_for_delete do
::Qiniu::RS.delete(bucket, path)
::Qiniu.delete(bucket, path)
end
@queued_for_delete = []
end
......@@ -58,7 +58,7 @@ module Paperclip
if @options[:qiniu_host]
"#{dynamic_fog_host_for_style(style)}/#{path(style)}"
else
res = ::Qiniu::RS.get(bucket, path(style))
res = ::Qiniu.get(bucket, path(style))
if res
res["url"]
else
......@@ -71,19 +71,19 @@ module Paperclip
def init
return if @inited
::Qiniu::RS.establish_connection! @options[:qiniu_credentials]
::Qiniu.establish_connection! @options[:qiniu_credentials]
inited = true
end
def upload(file, path)
upload_token = ::Qiniu::RS.generate_upload_token :scope => bucket
upload_token = ::Qiniu.generate_upload_token :scope => bucket
opts = {:uptoken => upload_token,
:file => file.path,
:key => path,
:bucket => bucket,
:mime_type => file.content_type,
:enable_crc32_check => true}
unless ::Qiniu::RS.upload_file(opts)
unless ::Qiniu.upload_file(opts)
raise Paperclip::Qiniu::UploadFailed
end
end
......
......@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = Paperclip::Qiniu::VERSION
gem.add_dependency 'paperclip'
gem.add_dependency 'qiniu-rs', '~> 3.0'
gem.add_dependency 'qiniu', '~> 6.4.1'
gem.add_development_dependency 'rspec'
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment