Commit 89fb0c2b by LI Daobing

Merge pull request #3 from liubin/liubin/upgrade-ruby-sdk

upgrade to new version of Ruby SDK
parents a6b0ab8d fe80d4c5
......@@ -15,6 +15,8 @@ example site: http://paperclip-qiniu-example.herokuapp.com/
```ruby
gem 'paperclip'
gem 'paperclip-qiniu'
# or get the latest version
# gem 'paperclip-qiniu', :git => "git://github.com/lidaobing/paperclip-qiniu"
```
* create `config/initializers/paperclip.rb`
......@@ -64,6 +66,10 @@ support options: `thumbnail`, `gravity`, `crop`, `quality`, `rotate`, `format`,
## CHANGELOG
### 0.1.1 (2015-01-06)
* upgrade Ruby SDK from `qiniu-rs` to `6.4.1`
### 0.1.0 (2012-09-06)
* add view helper: qiniu_image_tag, qiniu_image_path
......
module Paperclip
module Qiniu
VERSION = "0.1.0"
VERSION = "0.1.1"
end
end
......@@ -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