百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

carrierwave-qiniu

> 编程语言
开源

Qiniu 存储对 CarrierWave 的支持

176 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

Qiniu 存储对 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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubycarrierwavecarrierwave-qiniucarrierwave-storageqiniu

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

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