First thing we need to do is to install Amazon Web Service Command Line Interface (AWS CLI).
Depending on your environment, there are different ways to install AWS CLI. I’m using Mac OSX, and I prefer to install it via Homebrew brew install awscli
.
Then we need to configure awscli by running: aws configure
. You will be prompted to put your AWS Access Key Id, Secret Key, Region and Output. The following is an example:
Access key : foo
Secret key : bar
Region : us-west-1
Output : json
We are all set. Now, I gonna show you how we copy a specific file and an entire directory from Amazon S3.
Copy a file : aws s3 cp s3://bucket_name/dir/file.png local_path
Copy a directory : aws s3 cp --recursive s3://bucket_name/dir local_path
The example above, I show you how to copy a file, ‘file.png’, and an entire directory, ‘dir’, by specifying --recursive
option from Amazon S3 to your local machine or directory where you specify local_path
.
Enjoy!