No commit activity in last 3 years
No release in over 3 years
carrierwave_ucloud
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
>= 12.3
~> 3.0

Runtime

>= 0.16
 Project Readme

CarrierwaveUcloud

Ucloud Ufile CarrierWave Gem。

参考了aws/aliyun/ucloud多个已有CarrierWave插件的代码,感谢他们的付出。

Installation

Add this line to your application's Gemfile:

gem 'carrierwave_ucloud', '0.2.2'

And then execute:

$ bundle

Or install it yourself as:

$ gem install carrierwave_ucloud

Usage

配置文件:config/initializers/carrierwave.rb,内容如下:

# public / private 最少配置一套,配置2套可共存,uploader文件ucloud_public_read自己要对应好,暂时没有做任何校验逻辑
CarrierWave.configure do |config|
  config.storage = :ucloud
  config.ucloud_public_key = "public_key"
  config.ucloud_private_key = "private_key"
  config.ucloud_public_read = true # 默认使用public bucket,可在单个uploader覆写
  # public bucket配置
  config.ucloud_public_bucket = "public_bucket_name"
  # bucket 上传host,可设置ucloud提供的纯内网host(每个区不一样,例如:"http://public_bucket_name.ufile.cn-north-02.ucloud.cn"),或者配置和cdn访问host一样的
  config.ucloud_public_bucket_host = "http://public_bucket_name.cn-bj.ufileos.com"
  config.ucloud_public_cdn_host = "http://public_bucket_name.cn-bj.ufileos.com"
  config.ucloud_private_bucket = "private_bucket_name"
  # private bucket配置
  # bucket 上传host,可设置ucloud提供的纯内网host(每个区不一样,例如:"http://private_bucket_name.ufile.cn-north-02.ucloud.cn"),或者配置和cdn访问host一样的
  config.ucloud_private_bucket_host = "http://private_bucket_name.cn-bj.ufileos.com"
  config.ucloud_private_cdn_host = "http://private_bucket_name.cn-bj.ufileos.com"
  config.ucloud_private_expire_seconds = 300
end

全局配置ucloud_public_read,默认使用对应bucket配置,个别uploader如要用另外一种bucket配置,添加如下方法:

class XxxUploader < CarrierWave::Uploader::Base
  storage :ucloud

  def ucloud_public_read
    # true or false,XxxUploader以此配置选择bucket配置及逻辑
  end
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/carrierwave_ucloud. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the CarrierwaveUcloud project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.