Last active
April 27, 2020 04:08
-
-
Save jschee/76b77d421ddad49d4628d33d6bb02e47 to your computer and use it in GitHub Desktop.
active_storage tutorial aliyun as example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#step_1 create migration | |
#rails active_storage:install | |
#rails db:migrate | |
#step_2 add adapter gem of bucket provider | |
# e.g. gem 'activestorage/aliyun' | |
# bundle install | |
#step_3 configuration | |
# access keys credentials setup | |
# EDITOR=nano rails credentails:edit | |
# create bucket on alioss console | |
# name of bucket goes to bucket name in credentials | |
# url just copy paste domain of bucket, but also add https:// | |
# grab access key and access seceret from aliyun. generate thorugh profile/avatar | |
# copy/paste to credentails | |
# save/exit nano | |
# storage.yml (add aliyun credentails) | |
# aliyun: | |
# service: | |
# access_key: <%= Rails.application.credentails.dig(:aliyun, :access_key) %> | |
# mode: private(or pibic) | |
# ... | |
# Rails.application.credentials dig at bottom of storage.yml | |
# set rails_master_key= to production server | |
# eg dokku set:config appname RAILS_MASTER_KEY=... | |
# change active storage settings in environments point to :aliyun | |
#step_4 set attachment to model | |
# has_one_attached :avatar | |
# has_many_attached :photos | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment