require "qiniu_form/version" require 'uuid' require 'qiniu_form/rails' require 'qiniu_form/view_helpers/form_helper' require 'active_support/core_ext/hash' module QiniuForm class << self attr_accessor :upload_url, :key_prefix, :bucket, :download_host, :use_url_value def generate_uptoken(key, options) opts = options.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 def generate_upload_key [key_prefix, UUID.generate].join('/') end end end