Giter Site home page Giter Site logo

halczy / activestorage-aliyun Goto Github PK

View Code? Open in Web Editor NEW

This project forked from huacnlee/activestorage-aliyun

1.0 1.0 0.0 54 KB

Wraps the Aliyun OSS as an Active Storage service.

License: MIT License

Ruby 79.25% JavaScript 2.55% CSS 3.57% HTML 14.64%

activestorage-aliyun's Introduction

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.

activestorage-aliyun's People

Contributors

huacnlee avatar halczy avatar

Stargazers

zcy4coding avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.