In this article, we are going to learn how to upload a file(s) or  project to Amazon S3 using AWS CLI. To start with, first, we need to  have an AWS account.

What is Amazon S3?

Amazon S3 stands for Amazon Simple Storage Service. It  helps the developer community make computing scalable and more simple.  Amazon S3 provides a platform where developers can store and download  the data from anywhere and at any time on the web. Amazon S3 is a very  fast and reliable storage infrastructure.

Install AWS CLI

First when i run the following command i got an error because aws cli is not installed

aws --version

output
-bash: aws: command not found

So we need to install aws cli using apt on my Ubuntu 18.04 LTS

sudo apt install awscli

Check the AWS CLI version

$ aws --version

output
aws-cli/1.14.44 Python/3.6.8 Linux/4.15.0-1045-aws botocore/1.8.48

that’s great, now it’s time to configure the AWS credential.

Configure the AWS profile

$ aws configure
AWS Access Key ID [None]: <your access key>
AWS Secret Access Key [None]: <your secret key>
Default region name [None]: <your region name>
Default output format [None]: ENTER

All settings are done.
now you can access your s3 bucket.

Managing Buckets
aws s3 commands support commonly used bucket operations, such as creating, removing, and listing buckets.

1.Listing Buckets

$ aws s3 ls

output
2019-2-28 08:26:08 my-bucket1
2019-1-28 18:45:47 my-bucket2

The following command lists the objects in bucket-name/path (in other  words, objects in bucket-name filtered by the prefix path/).

$ aws s3 ls s3://bucket-name

2.Creating Buckets

$ aws s3 mb s3://bucket-name

(aws s3 mb command to create a new bucket. Bucket names must be unique.)

3.Removing Buckets
To remove a bucket, use the aws s3 rb command.

$ aws s3 rb s3://bucket-name

By default, the bucket must be empty for the operation to succeed. To  remove a non-empty bucket, you need to include the –force option.

$ aws s3 rb s3://bucket-name --force

This will first delete all objects and subfolders in the bucket and then remove the bucket.

Managing Objects
The high-level aws s3 commands make it convenient to manage Amazon S3  objects as well. The object commands include aws s3 cp, aws s3 ls, aws  s3 mv, aws s3 rm, and sync. The cp, ls, mv, and rm commands work  similarly to their Unix

The cp, mv, and sync commands include a –grants option that can be  used to grant permissions on the object to specified users or groups.  You set the –grants option to a list of permissions using the following  syntax:

--grants Permission=Grantee_Type=Grantee_ID
        [Permission=Grantee_Type=Grantee_ID ...]

Each value contains the following elements:
* Permission – Specifies the granted permissions, and can be set to read, readacl, writeacl, or full.
* Grantee_Type – Specifies how the grantee is to be identified and can be set to uri, email address, or id.
* Grantee_ID – Specifies the grantee based on Grantee_Type.
   * uri – The group’s URI. For more information, see Who Is a Grantee?
   * email address – The account’s email address.
   * id – The account’s canonical ID.

aws s3 cp file.txt s3://my-bucket/ --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers [email protected]

■Copy multiple files from directory
if you want to copy all files from a directory to s3 bucket, then checkout the below command.

aws s3 cp <your directory path> s3://<your bucket name> --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --recursive

We use the –recursive flag to indicate that ALL files must be copied recursively.
When passed with the parameter –recursive, the following cp command  recursively copies all files under a specified directory to a specified  bucket.

we can set exclude or include a flag, while copying files.

aws s3 cp <your directory path> s3://<your bucket name>/ --recursive --exclude "*.jpg"  --include "*.log"

For more details, please go through the aws official link.
https://docs.aws.amazon.com/cli/latest/userguide/using-s3-commands.html