Prerequisites:

An AWS account with necessary permissions.
AWS CLI installed and configured with your credentials.
A local file to upload.

Step-by-Step Guide:
  1. Create an S3 Bucket:
    You can create an S3 bucket using the AWS Management Console or the AWS CLI. For this example, we’ll assume you already have a bucket named my-bucket.
  2. Upload a File to S3:

aws s3 cp local_file.txt s3://my-bucket/path/to/file.txt

Replace local_file.txt with the path to your local file.

Replace my-bucket and path/to/file.txt with your desired bucket name and object key.

  1. Download a File from S3:

aws s3 cp s3://my-bucket/path/to/file.txt local_download_file.txt

Replace local_download_file.txt with the desired name for the downloaded file.

Explanation:

The aws s3 cp command is used for copying files between your local system and S3.

The source and destination paths are specified in the command.

The –recursive flag can be used to upload or download entire directories recursively.

Additional Considerations:

For large files, consider using multipart uploads for better performance and reliability.

You can use wildcards to upload or download multiple files.

Explore additional options like –acl, –storage-class, and –metadata for fine-grained control over your objects.

Example with Additional Options:

aws s3 cp –recursive my_local_folder/ s3://my-bucket/uploads/ –acl public-read

This command recursively uploads all files from the my_local_folder to the uploads folder in your S3 bucket, setting the ACL to public-read for easy access.

By following these steps and exploring the additional options, you can effectively manage your files in S3 using the AWS CLI.