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/ ...@@ -15,6 +15,8 @@ example site: http://paperclip-qiniu-example.herokuapp.com/
```ruby ```ruby
gem 'paperclip' gem 'paperclip'
gem 'paperclip-qiniu' gem 'paperclip-qiniu'
# or get the latest version
# gem 'paperclip-qiniu', :git => "git://github.com/lidaobing/paperclip-qiniu"
``` ```
* create `config/initializers/paperclip.rb` * create `config/initializers/paperclip.rb`
...@@ -64,6 +66,10 @@ support options: `thumbnail`, `gravity`, `crop`, `quality`, `rotate`, `format`, ...@@ -64,6 +66,10 @@ support options: `thumbnail`, `gravity`, `crop`, `quality`, `rotate`, `format`,
## CHANGELOG ## CHANGELOG
### 0.1.1 (2015-01-06)
* upgrade Ruby SDK from `qiniu-rs` to `6.4.1`
### 0.1.0 (2012-09-06) ### 0.1.0 (2012-09-06)
* add view helper: qiniu_image_tag, qiniu_image_path * add view helper: qiniu_image_tag, qiniu_image_path
......
module Paperclip module Paperclip
module Qiniu module Qiniu
VERSION = "0.1.0" VERSION = "0.1.1"
end end
end end
...@@ -5,9 +5,9 @@ module Paperclip ...@@ -5,9 +5,9 @@ module Paperclip
module Qiniu module Qiniu
def self.extended base def self.extended base
begin begin
require 'qiniu-rs' require 'qiniu'
rescue LoadError => e 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 raise e
end unless defined?(::Qiniu) end unless defined?(::Qiniu)
...@@ -25,7 +25,7 @@ module Paperclip ...@@ -25,7 +25,7 @@ module Paperclip
def exists?(style = default_style) def exists?(style = default_style)
init init
!!::Qiniu::RS.stat(bucket, path(style)) !!::Qiniu.stat(bucket, path(style))
end end
def flush_writes def flush_writes
...@@ -48,7 +48,7 @@ module Paperclip ...@@ -48,7 +48,7 @@ module Paperclip
def flush_deletes def flush_deletes
init init
for path in @queued_for_delete do for path in @queued_for_delete do
::Qiniu::RS.delete(bucket, path) ::Qiniu.delete(bucket, path)
end end
@queued_for_delete = [] @queued_for_delete = []
end end
...@@ -58,7 +58,7 @@ module Paperclip ...@@ -58,7 +58,7 @@ module Paperclip
if @options[:qiniu_host] if @options[:qiniu_host]
"#{dynamic_fog_host_for_style(style)}/#{path(style)}" "#{dynamic_fog_host_for_style(style)}/#{path(style)}"
else else
res = ::Qiniu::RS.get(bucket, path(style)) res = ::Qiniu.get(bucket, path(style))
if res if res
res["url"] res["url"]
else else
...@@ -71,19 +71,19 @@ module Paperclip ...@@ -71,19 +71,19 @@ module Paperclip
def init def init
return if @inited return if @inited
::Qiniu::RS.establish_connection! @options[:qiniu_credentials] ::Qiniu.establish_connection! @options[:qiniu_credentials]
inited = true inited = true
end end
def upload(file, path) 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, opts = {:uptoken => upload_token,
:file => file.path, :file => file.path,
:key => path, :key => path,
:bucket => bucket, :bucket => bucket,
:mime_type => file.content_type, :mime_type => file.content_type,
:enable_crc32_check => true} :enable_crc32_check => true}
unless ::Qiniu::RS.upload_file(opts) unless ::Qiniu.upload_file(opts)
raise Paperclip::Qiniu::UploadFailed raise Paperclip::Qiniu::UploadFailed
end end
end end
......
...@@ -15,6 +15,6 @@ Gem::Specification.new do |gem| ...@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"] gem.require_paths = ["lib"]
gem.version = Paperclip::Qiniu::VERSION gem.version = Paperclip::Qiniu::VERSION
gem.add_dependency 'paperclip' gem.add_dependency 'paperclip'
gem.add_dependency 'qiniu-rs', '~> 3.0' gem.add_dependency 'qiniu', '~> 6.4.1'
gem.add_development_dependency 'rspec' gem.add_development_dependency 'rspec'
end 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