Howdy.
How do you do?
Resuming our pursuit to store files in the cloud [:aws]...
Let's begin with creating our own bucket in AWS simple storage service(S3).
Create an AWS Console account and log on to your console.
To integrate AWS Simple Storage Service into our rails app we use a beautiful gem:
gem 'aws-sdk-s3'
Reference: rubygems.org/gems/aws-sdk-s3
To create your own bucket and integrate using Ruby, AWS provides a crystal clear documentation here:
AWS Simple Storage Service Ruby Documentation
In the newer version of Rails, editing and storing credentials is 2EZ.
In your terminal, run:
$EDITOR=gedit rails credentials:edit
# Use any editor of your choice
Copy/Paste your API access keys under the 'amazon:' section in the file, save it and close it.
Now head onto config/storage.yml,
amazon:
service: S3
access_key_id: "your_key_id"
secret_access_key: "your_secret_access_key"
# For Indian servers use Mumbai region as below
region: "ap-south-1"
bucket: "your_bucket_name"
Now when you upload :avatar when creating a new post the avatar file attachment gets stored in your cloud bucket as objects. Like for example:
Thats it for today.
For more interesting stuff wait for the next article.
Goodbye humans!
Love,
M.
liked_the_post == true ? comment and share : comment and share