Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

Download Files from S3 Bucket to Local Machine

Posted in AWS Tutorial
Updated on Dec 27, 2023
By Mari Selvan
👁️ 115 - Views
⏳ 4 mins
💬 1 Comment
Download Files from S3 Bucket to Local Machine

Photo Credit to CodeToFun

🙋 Introduction

Amazon Simple Storage Service (S3) is a widely-used object storage service provided by Amazon Web Services (AWS).

S3 allows you to store and retrieve any amount of data at any time. In this tutorial, we'll explore how to download files from an S3 bucket to your local machine using the AWS Command Line Interface (CLI).

📐 Prerequisites

Before you begin, ensure that you have the following:

  • An AWS account with appropriate permissions to access the desired S3 bucket.
  • AWS CLI installed on your local machine. You can download it here.

🎁 Getting Access Key ID and Secret Access Key

To get Access Key ID and Secret Access Key do the following:

  1. Login to you AWS Management Console
  2. Click on your account name on the top right corner and then click on Security credentials
    aws security credentials

    Photo Credit to CodeToFun

  3. Scroll down a little and create access key as follows:
    aws create access key

    Photo Credit to CodeToFun

  4. Congratulations, we have successfully created Access Key ID and Secret Access Key to download s3 items to our local machine.
    aws access key created successfully

    Photo Credit to CodeToFun

⚙️ Configure AWS CLI

Open a terminal or command prompt and run the following command to configure AWS CLI with your AWS credentials:

aws cli

Photo Credit to CodeToFun

Warning: Ensure to utilize your AWS credentials.

Congratulations! You are now ready to download your S3 bucket to your local machine.

📄 Downloading Single File

For downloading an individual file from S3 to your local machine, kindly execute the following command:

  • aws s3 cp s3://your-bucket-name/path/to/image.jpg /path/on/local/machine/
    aws s3 download one image

    Photo Credit to CodeToFun

🗂️ Downloading All Files

For downloading all files from S3 to your local machine, kindly execute the following command:

  • aws s3 cp --recursive "s3://your-bucket-name/" /path/on/local/machine/
    aws s3 download one image

    Photo Credit to CodeToFun

📁 Downloading All Files with Exception

For downloading all files from S3 except certain files to your local machine, kindly execute the following command:

  • aws s3 cp --recursive "s3://your-bucket-name/" /path/on/local/machine/ . --exclude "*" --include "*.jpg"
    aws s3 download one image

    Photo Credit to CodeToFun

    We are downloading all files with the .jpg extension in this process.

🎉 Conclusion

Downloading files from an S3 bucket to your local machine is a straightforward process using the AWS CLI. With the proper configuration and commands, you can efficiently transfer files and directories between your S3 storage and local environment.

Feel free to explore additional options and customize the commands based on your specific requirements. Happy downloading!

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Mari Selvan
Mari Selvan
4 months ago

If you have any doubts regarding this article (Download Files from S3 Bucket to Local Machine), please comment here. I will help you immediately.

We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy