jj# QiniuForm

Rails Qiniu Upload form

Installation

Add this line to your application's Gemfile:

gem 'qiniu_form'

And then execute:

$ bundle

Or install it yourself as:

$ gem install qiniu_form

Usage

Init

Update file: config/initialize/qiniu_from.rb

QiniuForm.upload_url = 'http://up.qiniu.com'
QiniuForm.key_prefix = 'play'
QiniuForm.bucket = 'my_bucket'
QiniuForm.download_host = 'http://my_bucket.qiniu.download.com'
QiniuForm.use_url_value = true # field value: (host + key) or (only key)

Update file app/assets/javascripts/application.js

# = require 'qiniu_form'

Update file app/assets/stylesheets/application.scss, (require scss)

/*
 * = require 'qiniu_form'
*/

copy qiniu_from/vendoc/views/_qiniu_upload_field.html.slim to app/views/application/_qiniu_upload_field

Rails views

- form_for @user do |f|
  = f.qiniu_upload_field :name
  = f.qiniu_upload_field :name, value: 'url'
  = f.qiniu_upload_field :name, value: 'url', type: :image || :audio || :video || :file

= qiniu_upload_tag :name, 'value url'
= qiniu_upload_tag :name, 'value url', type: :image

Contributing

  1. Fork it ( https://github.com/[my-github-username]/qiniu_form/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request