Module: QiniuForm
- Defined in:
- lib/qiniu_form.rb,
lib/qiniu_form/rails.rb,
lib/qiniu_form/version.rb,
lib/qiniu_form/rails/engine.rb
Defined Under Namespace
Modules: Rails
Constant Summary collapse
- VERSION =
"0.0.2"
Class Attribute Summary collapse
-
.bucket ⇒ Object
Returns the value of attribute bucket.
-
.download_host ⇒ Object
Returns the value of attribute download_host.
-
.key_prefix ⇒ Object
Returns the value of attribute key_prefix.
-
.upload_url ⇒ Object
Returns the value of attribute upload_url.
-
.use_url_value ⇒ Object
Returns the value of attribute use_url_value.
Class Method Summary collapse
Class Attribute Details
.bucket ⇒ Object
Returns the value of attribute bucket.
11 12 13 |
# File 'lib/qiniu_form.rb', line 11 def bucket @bucket end |
.download_host ⇒ Object
Returns the value of attribute download_host.
11 12 13 |
# File 'lib/qiniu_form.rb', line 11 def download_host @download_host end |
.key_prefix ⇒ Object
Returns the value of attribute key_prefix.
11 12 13 |
# File 'lib/qiniu_form.rb', line 11 def key_prefix @key_prefix end |
.upload_url ⇒ Object
Returns the value of attribute upload_url.
11 12 13 |
# File 'lib/qiniu_form.rb', line 11 def upload_url @upload_url end |
.use_url_value ⇒ Object
Returns the value of attribute use_url_value.
11 12 13 |
# File 'lib/qiniu_form.rb', line 11 def use_url_value @use_url_value end |
Class Method Details
.generate_upload_key ⇒ Object
29 30 31 |
# File 'lib/qiniu_form.rb', line 29 def generate_upload_key [key_prefix, UUID.generate].join('/') end |
.generate_uptoken(key, options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/qiniu_form.rb', line 13 def generate_uptoken(key, ) opts = .symbolize_keys key ||= generate_upload_key scope = "#{bucket}:#{key}" opts[:deadline] ||= Time.now + 30.minutes # callback_body = BASE_CALLBACK_BODY.map {|k, v| "#{k}=#{v}"}.join('&') # if opts[:persistent_ops] # opts[:persistent_notify_url] ||= PERSISTENT_CALLBACK_URL # end token = Qiniu.generate_upload_token({scope: scope}.merge!(opts.compact)) {:token => token, :key => key} end |