Sha256: 2f2066c98853df8e808f009d31eb3e95b6d64e1b3450863d4eebf9bf5d579409

Contents?: true

Size: 876 Bytes

Versions: 2

Compression:

Stored size: 876 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qiniu_form-0.0.2 lib/qiniu_form.rb
qiniu_form-0.0.1 lib/qiniu_form.rb