Sha256: a9fcc803811884fd86ef125d6a66fb48895f68fc56a920cfc7f2583e59688914
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
module ActionView module Helpers module Tags class QiniuUploadField < Base 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 class << self def field_type @field_type ||= self.name.split("::").last.sub("Field", "").downcase end end private def field_type self.class.field_type end 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 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
qiniu_form-0.0.2 | lib/qiniu_form/view_helpers/tags/qiniu_upload_field.rb |
qiniu_form-0.0.1 | lib/qiniu_form/view_helpers/tags/qiniu_upload_field.rb |