Commit a6c4796e by LI Daobing

use qiniu-rs v3

parent 354d9341
......@@ -3,7 +3,7 @@ PATH
specs:
paperclip-qiniu (0.0.2)
paperclip
qiniu-rs
qiniu-rs (~> 3.0)
GEM
remote: https://rubygems.org/
......
module Paperclip
module Qiniu
class Error < StandardError; end
class UploadFailed < Error; end
end
end
require 'paperclip-qiniu/exceptions'
module Paperclip
module Storage
module Qiniu
......@@ -74,14 +76,16 @@ module Paperclip
end
def upload(file, path)
remote_upload_url = ::Qiniu::RS.put_auth
opts = {:url => remote_upload_url,
upload_token = ::Qiniu::RS.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}
::Qiniu::RS.upload opts
unless ::Qiniu::RS.upload_file(opts)
raise Paperclip::Qiniu::UploadFailed
end
end
def bucket
......
......@@ -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'
gem.add_dependency 'qiniu-rs', '~> 3.0'
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