class ActionView::Helpers::Tags::QiniuUploadField
Public Class Methods
field_type()
click to toggle source
# File lib/qiniu_form/view_helpers/tags/qiniu_upload_field.rb, line 32 def field_type @field_type ||= self.name.split("::").last.sub("Field", "").downcase end
Public Instance Methods
render()
click to toggle source
# File lib/qiniu_form/view_helpers/tags/qiniu_upload_field.rb, line 6 def render options = @options.stringify_keys add_default_name_and_id(options) options['value'] ||= value(object) options['type'] ||= 'image' form_data = qiniu_upload_params(options).to_json @template_object.render({ :partial => 'qiniu_upload_field', :locals => { form_data: form_data, url: QiniuForm.upload_url, uuid: UUID.generate, name: options['name'], title: options['title'], value: options['value'], type: options['type'], mime_limit: options['mime_limit'], download_host: QiniuForm.download_host, url_value: QiniuForm.use_url_value ? 'true' : nil } }) end
Private Instance Methods
field_type()
click to toggle source
# File lib/qiniu_form/view_helpers/tags/qiniu_upload_field.rb, line 39 def field_type self.class.field_type end
qiniu_upload_params(opts)
click to toggle source
# File lib/qiniu_form/view_helpers/tags/qiniu_upload_field.rb, line 43 def qiniu_upload_params(opts) upload_params = opts.slice('fsize_limit', 'mime_limit', 'deadlime') key = QiniuForm.generate_upload_key # persistent_ops = ConnettTools::Qiniu.persistent_cmd(key, opts['type']) # upload_params['persistent_ops'] ||= persistent_ops if persistent_ops QiniuForm.generate_uptoken(key, upload_params) end