Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Rails 3 library that uploads all static assets to aliyun oss with a unique id encoded into the path
Ruby
branch: master

This branch is 8 commits ahead of moocode:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib 缓存过期思路
test 忽略gz文件
LICENSE initial commit
README.md fix doc
README_EN.textile 中文文档
asset_oss.gemspec beta

README.md

Asset OSS - 上传Rails项目静态文件到Aliyun OSS

关于

基于asset_id,aset_sync也许是更好的选择

一个简单的上传Rails assets目录里静态文件到Aliyun OSS工具

使用和配置

添加gem "asset_oss"到你的Gemfile

修改config/environments/production.rb文件, config.action_controller.asset_host = "http://my_live_bucket.oss.aliyuncs.com"

新建一个config/asset_oss.yml文件

production:
  host: 'oss.aliyuncs.com'
  access_key_id: 'MY_ACCESS_KEY'
  secret_access_key: 'MY_ACCESS_SECRET'
  bucket: "my_live_bucket"

创建rake任务, lib/tasks/asset_oss.rake

namespace :asset do
  namespace :oss do

    desc "uploads the current assets to aliyun oss with stamped ids"
    task :upload do
      AssetOSS::Asset.asset_paths += ['assets'] # Configure additional asset paths
      AssetOSS::OSS.upload
    end

  end
end

其它

也许可以通过修改Rails config.assets.prefix实现缓存过期,记得prefix要是assets开头,同时修改AssetOSS::Asset.asset_paths

Something went wrong with that request. Please try again.