Building Serverless Web Applications
上QQ阅读APP看书,第一时间看更新

Using S3 with the CLI

The Management Console is very useful to upload and download files from S3, but so is the CLI. Let's play with the CLI in this section to gain more familiarity. We will create a bucket and store a file by performing the following steps. Those will be useful later for the AWS Lambda demo:

  1. First, choose a bucket name and use the make-bucket command:
        aws s3 mb s3://my-bucket-name
  1. Now, create a file named test.txt and write something to it.
  2. Copy the file to your new bucket setting the Access Control List (ACL) as public content:
        aws s3 cp test.txt s3://my-bucket-name/ --acl public-read
  1. List the bucket contents using the following command line:
        aws s3 ls s3://my-bucket-name
  1. Download the file as test2.txt by using the following command line:
        aws s3 cp s3://my-bucket-name/test.txt test2.txt
For more commands, refer to the official guide at http://docs.aws.amazon.com/cli/latest/userguide/using-s3-commands.html.