Skip to content
This repository has been archived by the owner on Nov 6, 2018. It is now read-only.

Wraps the Aliyun OSS as an Active Storage service.

License

Notifications You must be signed in to change notification settings

halczy/activestorage-aliyun

 
 

Repository files navigation

ActiveStorage Aliyun Service

Wraps the Aliyun OSS as an Active Storage service.

Gem Version Build Status Code Climate codecov.io

Installation

Add this line to your application's Gemfile:

gem 'activestorage-aliyun'

And then execute:

$ bundle

Usage

config/storage.yml

production:
  service: Aliyun
  access_key_id: "your-oss-access-key-id"
  access_key_secret: "your-oss-access-key-secret"
  bucket: "bucket-name"
  endpoint: "https://oss-cn-beijing.aliyuncs.com"
  # path prefix, default: /
  path: "my-app-files"
  # Bucket mode: [public, private], default: public
  mode: "public"

Use for image url

Orignial File URL:

<%= image_tag @photo.image.service_url %>

Thumb with OSS image service:

class Photo < ApplicationRecord
  def image_thumb_url(process)
    self.image.service_url(params: { "x-oss-process" => process })
  end
end

And then:

<%= image_tag @photo.image.image_thumb_url("image/resize,h_100,w_100") %>

Use for file download

If you want to get original filename (Include Chinese and other UTF-8 chars), for example: 演示文件 download.zip, you need present disposition: :attachment option.

#
<%= image_tag @photo.image.service_url(disposition: :attachment) %>

Contributing

Contribution directions go here.

License

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

About

Wraps the Aliyun OSS as an Active Storage service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 79.3%
  • HTML 14.6%
  • CSS 3.6%
  • JavaScript 2.5%