• Stars
    star
    131
  • Rank 275,963 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Wraps the Aliyun OSS as an Active Storage service.

ActiveStorage Aliyun Service

Wraps the Aliyun OSS as an Active Storage service, use Aliyun official Ruby SDK for upload.

Gem Version build

Installation

Add this line to your application's Gemfile:

gem "activestorage-aliyun"

And then execute:

$ bundle

Usage

NOTE! Current document work for Rails 6.1, if you are using Rails 6.0, please visit: https://github.com/huacnlee/activestorage-aliyun/tree/v0.6.4 You can also to use activestorage-aliyun 1.0.0 in Rails 6.0

config/storage.yml

aliyun:
  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 public: true/false, default: true, for generate public/private URL.
  public: true

Custom Domain

aliyun:
  service: Aliyun
  access_key_id: "your-oss-access-key-id"
  access_key_secret: "your-oss-access-key-secret"
  bucket: "bucket-name"
  endpoint: "https://file.myhost.com"
  public: false
  # Enable cname to use custom domain
  cname: true

Use for image url

Original File URL:

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

Thumb with OSS image service:

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

And then:

<%= image_tag @photo.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.url(disposition: :attachment) %>

Contributing

Run test

$ bin/test test/activestorage_aliyun_test.rb
# run a line
$ bin/test test/activestorage_aliyun_test.rb:129

License

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

More Repositories

1

rails-settings-cached

Global settings for your Rails application.
Ruby
1,005
star
2

flora-kit

💐 基于 shadowsocks-go 做的完善实现,自动网络分流,完全兼容 Surge 的配置文件。
Go
898
star
3

autocorrect

A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuations between CJK (Chinese, Japanese, Korean).
Rust
887
star
4

redis-search

Deprecated! High performance real-time prefix search, indexes store in Redis for Rails application
Ruby
712
star
5

rucaptcha

Captcha Gem for Rails, which generates captcha image by Rust.
Ruby
686
star
6

quora

Quora.com like project with Ruby on Rails (不再维护)
JavaScript
684
star
7

init.d

⚙️ Batch scripts for Rails production environment install on Ubuntu Server.
678
star
8

bluedoc

An open-source document management tool for enterprise self host.
Ruby
626
star
9

social-share-button

Helper for add social share feature in your Rails app. Twitter, Facebook, Weibo, Douban ...
CoffeeScript
581
star
10

PokemonGoMove

Pokemon GO iOS GPS Emulator - NO Jailbreak needed, lets you play the game on your Mac :)
Python
412
star
11

imax.im

🎬 Source code of IMAX.im
Ruby
366
star
12

mediom

Forum web application, an example for from Rails to Go (Revel)
Go
355
star
13

jquery.qeditor

This is a simple WYSIWYG editor with jQuery.
CoffeeScript
259
star
14

carrierwave-aliyun

阿里云 OSS Ruby 上传组件,基于 Carrierwave
Ruby
195
star
15

auto-correct

Automatically add whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).
Ruby
142
star
16

sails

Create a Thrift Server use like Rails
Ruby
71
star
17

turbolinks-prefetch

Turbolinks extends for prefetch links to speeds up your website.
JavaScript
70
star
18

personlab

我博客的源代码,这个代码较老,不推荐拿来学习
Ruby
69
star
19

vimmate

Custom vim like Textmate for Ruby on Rails development
Vim Script
69
star
20

mongoid_auto_increment_id

Override id field to MySQL like auto increment for Mongoid.
Ruby
65
star
21

hello-go

入门 Go 编写应用
Go
57
star
22

pasite

Share your sources code on the web, see the http://pasite.org
Ruby
55
star
23

zed-theme-macos-classic

A macOS native style theme for Zed, let it same like native app in macOS.
JavaScript
49
star
24

sql-builder

A simple SQL builder for generate SQL for non-ActiveRecord supports databases
Ruby
36
star
25

rails-activestorage-example

Rails use Active Storage the right way
Ruby
30
star
26

redmine-theme-innerboard

Innerboard theme for Redmine
26
star
27

cocoaout

Auto build and release tool for Cocoa projects.
Ruby
25
star
28

enumize

Extend ActiveRecord::Enum for add more helpful methods.
Ruby
24
star
29

jquery.lazyimg

Image lazy load plugin for jQuery, fork from jquery.unveil to improve performance with huge DOMs.
CoffeeScript
23
star
30

gitlab-mail-receiver

The way of allow your GitLab support Email receive and parse the email content, and find Issue/MergeRequest to create reply.
Ruby
23
star
31

redis-search-example

An example for use redis-search gem
JavaScript
23
star
32

ip-location

通过淘宝 IP 库查询 IP 所在地域位置 http://ip.taobao.com
Ruby
18
star
33

mongoid_taggable_on

Taggable on custom fields for Mongoid
Ruby
16
star
34

vscode-macos-classic.theme

macOS Classic theme for Visual Studio Code
Makefile
15
star
35

backup-aliyun

Aliyun OSS storage with Backup
Ruby
12
star
36

jdialog

a jQuery popup window plugin
JavaScript
12
star
37

html-pipeline.cr

HTML processing filters and utilities for Crystal.
Crystal
11
star
38

vue-rails-example

Use Vue.js in Rails 6 example
Ruby
9
star
39

actiontext-lite

Lite version of ActionText
Ruby
7
star
40

autocorrect-action

GitHub action for use AutoCorrect as lint
Shell
6
star
41

zed-extension-action

GitHub Action for automatically bump Zed Extensions version after a release.
JavaScript
6
star
42

docker-rails

Deploy Rails via Docker example
Ruby
5
star
43

booklib

php + Codeigniter Library management tool
PHP
4
star
44

vscode-blackboard-plus.theme

Visual Studio Code - Blackboard Plus Theme
4
star
45

zed-csv

CSV support for Zed
Rust
4
star
46

remarkdown

This is extends of Markdown lib from Crystal Stdlib for Support Markdown GFM.
Crystal
4
star
47

huacnlee.github.io

Ruby
3
star
48

vscode-autocorrect

AutoCorrect for VS Code
TypeScript
3
star
49

sidekiq-activerecord-shard

Sidekiq middleware to supports ActiveRecord 7 shard
Ruby
3
star
50

autocorrect-idea-plugin

AutoCorrect Plugin for IntelliJ IDEA
Kotlin
2
star
51

auto-booking-park

Shell
2
star
52

jselectdate

jQuery date choice control with dropdown list
JavaScript
2
star
53

capistrano-upload-configs

Capistrano plugin for Upload local config files to remote, and create soft link.
Ruby
2
star
54

zed-autocorrect

AutoCorrect for Zed
Rust
2
star
55

micro-web-simple

Go
1
star
56

jimagelink

模拟yupoo的缩略图上的小图标效果的jQuery插件
JavaScript
1
star
57

jcaches

client side cache with Javascript
JavaScript
1
star
58

yjs-server

JavaScript
1
star
59

Light-Classic.tmTheme

Improve of TextMate Light Theme from Mac Classic
1
star