module Qiniu
vim: sw=2 ts=2
AccessToken
类已经过时,请改用 Qiniu::Auth.generate_acctoken
方法 ###
DownloadToken
类已经过时,请改用 Qiniu::Auth.authorize_download_url
方法 ### 或 Qiniu::Auth.authorize_download_url_2
方法 ###
UploadToken
类已经过时,请改用 Qiniu::Auth.generate_uptoken
方法 ###
Constants
- StatusOK
Public Class Methods
batch(command, bucket, keys)
click to toggle source
# File lib/qiniu.rb, line 129 def batch(command, bucket, keys) code, data = Storage.batch(command, bucket, keys) code == StatusOK ? data : false end
batch_copy(*args)
click to toggle source
# File lib/qiniu.rb, line 139 def batch_copy(*args) code, data = Storage.batch_copy(args) code == StatusOK end
batch_delete(bucket, keys)
click to toggle source
# File lib/qiniu.rb, line 149 def batch_delete(bucket, keys) code, data = Storage.batch_delete(bucket, keys) code == StatusOK ? data : false end
batch_move(*args)
click to toggle source
# File lib/qiniu.rb, line 144 def batch_move(*args) code, data = Storage.batch_move(args) code == StatusOK end
batch_stat(bucket, keys)
click to toggle source
# File lib/qiniu.rb, line 134 def batch_stat(bucket, keys) code, data = Storage.batch_stat(bucket, keys) code == StatusOK ? data : false end
buckets()
click to toggle source
# File lib/qiniu.rb, line 46 def buckets code, data = Storage.buckets code == StatusOK ? data : false end
copy(source_bucket, source_key, target_bucket, target_key)
click to toggle source
# File lib/qiniu.rb, line 109 def copy(source_bucket, source_key, target_bucket, target_key) code, data = Storage.copy(source_bucket, source_key, target_bucket, target_key) code == StatusOK end
delete(bucket, key)
click to toggle source
# File lib/qiniu.rb, line 119 def delete(bucket, key) code, data = Storage.delete(bucket, key) code == StatusOK end
drop(bucket)
click to toggle source
# File lib/qiniu.rb, line 154 def drop(bucket) code, data = Storage.drop(bucket) code == StatusOK end
establish_connection!(opts = {})
click to toggle source
# File lib/qiniu.rb, line 25 def establish_connection!(opts = {}) Config.initialize_connect opts end
establish_https_connection!(opts = {})
click to toggle source
# File lib/qiniu.rb, line 29 def establish_https_connection!(opts = {}) Config.initialize_connect_https opts end
fetch(bucket, target_url, key)
click to toggle source
# File lib/qiniu.rb, line 124 def fetch(bucket, target_url, key) code, data = Storage.fetch(bucket, target_url, key) code == StatusOK end
generate_download_token(opts = {})
click to toggle source
# File lib/qiniu.rb, line 193 def generate_download_token(opts = {}) token_obj = DownloadToken.new(opts) token_obj.access_key = Config.settings[:access_key] token_obj.secret_key = Config.settings[:secret_key] #token_obj.expires_in = opts[:expires_in] #token_obj.pattern = opts[:pattern] token_obj.generate_token end
generate_upload_token(opts = {})
click to toggle source
# File lib/qiniu.rb, line 178 def generate_upload_token(opts = {}) token_obj = UploadToken.new(opts) token_obj.access_key = Config.settings[:access_key] token_obj.secret_key = Config.settings[:secret_key] #token_obj.scope = opts[:scope] #token_obj.expires_in = opts[:expires_in] #token_obj.callback_url = opts[:callback_url] #token_obj.callback_body_type = opts[:callback_body_type] #token_obj.customer = opts[:customer] #token_obj.escape = opts[:escape] #token_obj.async_options = opts[:async_options] #token_obj.return_body = opts[:return_body] token_obj.generate_token end
image_exif(url)
click to toggle source
# File lib/qiniu.rb, line 164 def image_exif(url) code, data = Fop::Image.exif(url) code == StatusOK ? data : false end
image_info(url)
click to toggle source
# File lib/qiniu.rb, line 159 def image_info(url) code, data = Fop::Image.info(url) code == StatusOK ? data : false end
image_mogrify_preview_url(source_image_url, options)
click to toggle source
# File lib/qiniu.rb, line 169 def image_mogrify_preview_url(source_image_url, options) Fop::Image.mogrify_preview_url(source_image_url, options) end
image_mogrify_save_as(bucket, key, source_image_url, options)
click to toggle source
# File lib/qiniu.rb, line 173 def image_mogrify_save_as(bucket, key, source_image_url, options) code, data = Storage.image_mogrify_save_as(bucket, key, source_image_url, options) code == StatusOK ? data : false end
mkbucket(bucket_name)
click to toggle source
# File lib/qiniu.rb, line 41 def mkbucket(bucket_name) code, data = Storage.mkbucket(bucket_name) code == StatusOK end
move(source_bucket, source_key, target_bucket, target_key)
click to toggle source
# File lib/qiniu.rb, line 114 def move(source_bucket, source_key, target_bucket, target_key) code, data = Storage.move(source_bucket, source_key, target_bucket, target_key) code == StatusOK end
set_protected(bucket, protected_mode)
click to toggle source
# File lib/qiniu.rb, line 51 def set_protected(bucket, protected_mode) code, data = Misc.set_protected(bucket, protected_mode) code == StatusOK end
set_separator(bucket, separator)
click to toggle source
# File lib/qiniu.rb, line 56 def set_separator(bucket, separator) code, data = Misc.set_separator(bucket, separator) code == StatusOK end
set_style(bucket, name, style)
click to toggle source
# File lib/qiniu.rb, line 61 def set_style(bucket, name, style) code, data = Misc.set_style(bucket, name, style) code == StatusOK end
stat(bucket, key)
click to toggle source
# File lib/qiniu.rb, line 104 def stat(bucket, key) code, data = Storage.stat(bucket, key) code == StatusOK ? data : false end
switch_to_http!()
click to toggle source
# File lib/qiniu.rb, line 33 def switch_to_http! Config.switch_to_http end
switch_to_https!()
click to toggle source
# File lib/qiniu.rb, line 37 def switch_to_https! Config.switch_to_https end
unset_style(bucket, name)
click to toggle source
# File lib/qiniu.rb, line 66 def unset_style(bucket, name) code, data = Misc.unset_style(bucket, name) code == StatusOK end
upload_file(opts = {})
click to toggle source
# File lib/qiniu.rb, line 71 def upload_file opts = {} uncontained_opts = [:uptoken, :file, :bucket, :key] - opts.keys raise MissingArgsError, uncontained_opts unless uncontained_opts.empty? source_file = opts[:file] raise NoSuchFileError, source_file unless File.exist?(source_file) opts[:enable_resumable_upload] = true unless opts.has_key?(:enable_resumable_upload) if opts[:enable_resumable_upload] && File::size(source_file) > Config.settings[:block_size] code, data, raw_headers = Storage.resumable_upload_with_token(opts[:uptoken], opts[:file], opts[:bucket], opts[:key], opts[:mime_type], opts[:customer], opts[:callback_params], opts[:rotate]) else code, data, raw_headers = Storage.upload_with_token(opts[:uptoken], opts[:file], opts[:bucket], opts[:key], opts[:mime_type], opts[:note], opts[:callback_params], opts[:enable_crc32_check], opts[:rotate]) end raise UploadFailedError.new(code, data) if code != StatusOK return data end