top of page

Tutorial learn Copying multiple files between your local machine and AWS CloudShell

Learning Objective:

  • Use S3 buckets to copy files between your local machine and CloudShell.

  • Compress multiple files in a single zipped folder that can be uploaded or downloaded using the CloudShell interface.

Uploading and downloading multiple files using Amazon S3

Prerequisites

To work with buckets and objects, you need an IAM policy that grants permissions to perform the following Amazon S3 API actions:

s3:CreateBucket

s3: PutObject

s3: GetObject

Step 1:

In the top right corner of AWS console click on CloudShell icon.

This window will show up.

Upload multiple files to AWS CloudShell using Amazon S3

1. In AWS CloudShell, create an S3 bucket by running the following s3 command:

aws s3api create-bucket --bucket cloud-plusplus --region us-east-1

If the call is successful, the command line displays a response from the S3 service:

You can replace your bucket name with cloud-plusplus

2. Upload the files in a directory from your local machine to the bucket. Choose one of the following options to upload files:

  • AWS Management Console: Use drag-and-drop to upload files and folders to a bucket.

3. Return to the CloudShell command line and enter the following command to synchronize the directory in the shell environment with the contents of the S3 bucket:

aws s3 sync s3://your-bucket-name folder-path

If the sync is successful, download messages are displayed for every file downloaded from the bucket to the directory.

Download multiple files from AWS CloudShell using Amazon S3

1. Using the AWS CloudShell command line, enter the following aws s3 command to sync an S3 bucket with contents of the current directory in the shell environment:

aws s3 sync folder-path s3://your-bucket-name

2. Download the contents of the bucket to your local machine. Because the Amazon S3 console doesn't support the downloading of multiple objects, you need to use the AWS CLI tool that's installed on your local machine.

From the command line of the AWS CLI tool,

run the following command:

aws s3 sync s3://your-bucket-name folder-path

If the sync is successful, the command line displays a download message for each file updated or added in the destination directory.

Uploading and downloading multiple files using zipped folders

With the zip/unzip utilities, you can compress multiple files in an archive that can be treated as a single file. The utilities are pre-installed in the CloudShell compute environment.

In the CloudShell command line, run the following command to unzip the contents of the zip archive to a specified directory. replace your file name with red part.

unzip zipped-files.zip -d my-unzipped-folder

Download multiple files from AWS CloudShell using zipped folders.

In the CloudShell command line, running the following command to add all the files in the current directory to a zipped folder:

zip -r zipped-archive.zip *

Choose Actions, Download file.

In the Download file dialog box, enter the path for the zipped folder (/home/cloudshell-user/zip-folder/zipped-archive.zip, for example), and then choose Download.

If the path is correct, a browser dialog offers the choice of opening the zipped folder or saving it to your local machine.

On your local machine, you can now unzip the contents of the downloaded zipped folder

Note: If you no longer need this CloudShell environment delete it.


CloudShell
.pdf
Download PDF • 421KB

Was this document helpful? How can we make this document better. Please provide your insights. You can download PDF version for reference.


For your aws certification needs or for aws learning contact us.





Recent Posts

See All

9 Comments


Very useful sir

Like

Easy to understand sir

Like

Helpful and well defined

Like

Atchaya B
Atchaya B
Mar 21

Useful blog.

Like

Gokulnath
Gokulnath
Mar 21

👍👌

Like
bottom of page