After installing AWS, I uploaded an image from the application under development in the local environment and tried to check if the actually saved thing was saved in S3, but I got an error like this time.
It will be like that.
:access_key_id :secret_access_key :credentials
....
This means that they may have picked up those credentials correctly and not read them.
In order to be able to save to S3, I prepared a bucket so that data can be stored in S3, and set the region and check box appropriately. The bucket policy also definitely entered the user's ARN and bucket name.
Then, I assigned the environment variables in the terminal and confirmed that the description of conflict / environments / production.rb and the description of config / storage.yml were done correctly.
confing/environments/production.rb
config.active_storage.service = :amazon
confing/environment/development.rb
config.active_storage.service = :amazon
config/storage.yml
amazon:
service: S3
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
region: ap-northeast-1
bucket:Bucket name
Check if it works properly with vim ~ / .zshrc command or source ~ / .zshrc command
A command to execute after entering a key in vim ~ / .zshrc and saving. A command that allows you to use the variables added as environment variables after reloading .zshrc.
If you don't do that, you'll get an error saying that you can't upload the image. I would like to remember to do what I made a mistake from the next time.
Recommended Posts