・ Ruby: 2.5.7 Rails: 5.2.4 ・ Vagrant: 2.2.7 -VirtualBox: 6.1 ・ OS: macOS Catalina
Perform up to "making keys into environment variables" in ʻAWS settings and
implementation` in the following article.
How to upload images to AWS S3 using Carrierwave and fog-aws
refile.rb
Terminal
$ touch config/initializers/refile.rb
refile.rb
require 'refile/s3'
if Rails.env.production? #Upload to S3 in production environment
aws = {
access_key_id: ENV['S3_ACCESS_KEY_ID'], #Access key ID
secret_access_key: ENV['S3_SECRET_ACCESS_KEY'], #Secret access key
region: 'ap-northeast-1', #region
bucket: 'matsubishi-sample', #Bucket name
}
Refile.cache = Refile::S3.new(prefix: 'cache', **aws)
Refile.store = Refile::S3.new(prefix: 'store', **aws)
end
Recommended Posts