Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

carrierwave-qiniu

> 编程语言
Open source

Qiniu Storage support for CarrierWave

176 stars0 likes2 views
WebsiteGitHub

About

Qiniu Storage support for CarrierWave

Carrierwave::Qiniu

This gem adds storage support for Qiniu to Carrierwave

example: https://github.com/huobazi/carrierwave-qiniu-example

Installation

Add the following to your application's Gemfile:

gem 'carrierwave-qiniu', '~> 1.2.2'
gem 'carrierwave-i18n' # If you need to use locales other than English

And then execute:

$ bundle

Or install it yourself as:

$ gem install carrierwave-qiniu -v 1.2.2

Usage

You'll need to configure it in config/initializers/carrierwave.rb

ruby
::CarrierWave.configure do |config|
  config.storage              = :qiniu
  config.qiniu_access_key     = "your qiniu access_key"
  config.qiniu_secret_key     = 'your qiniu secret_key'
  config.qiniu_bucket         = "carrierwave-qiniu-example"
  config.qiniu_bucket_domain  = "carrierwave-qiniu-example.aspxboy.com"
  config.qiniu_bucket_private = true #default is false
  config.qiniu_block_size     = 4*1024*1024
  config.qiniu_protocol       = "http"
  config.qiniu_up_host        = 'http://up.qiniug.com' #七牛上传海外服务器,国内使用可以不要这行配置
end

For more information on qiniu, please read http://developer.qiniu.com/docs/v6/

And then in your uploader, set the storage to :qiniu:

ruby
class AvatarUploader  'imageView/0/w/400', :xlarge => 'imageView/0/w/1600'

  self.qiniu_bucket        = "avatars"
  self.qiniu_bucket_domain = "avatars.files.example.com"

end

user.avatar.url(:thumb, inline: true)
# http://.../avatar.jpg?imageView2/1/w/400

Sync Qiniu styles of uploader

$ rake carrierwave:qiniu:sync_styles

# Bucket: bucket_name_1, Set style: thumb => imageView2/1/w/200
# Bucket: bucket_name_2, Set style: large => imageView2/1/w/800

You can see a example project on: https://github.com/huobazi/carrierwave-qiniu-example

or see the spec test on https://github.com/huobazi/carrierwave-qiniu/blob/master/spec/carrierwave-qiniu_spec.rb

LICENSE

See the LICENSE.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contributors

See the Contributors List.

CHANGE LOG

See the CHANGELOGS.md.

Issues· 4 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubycarrierwavecarrierwave-qiniucarrierwave-storageqiniu

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言