0
0
AWScloud~30 mins

Uploading and downloading objects in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Uploading and downloading objects
📖 Scenario: You are working with Amazon S3, a cloud storage service. You want to upload a file to a bucket and then download it back to your local machine.
🎯 Goal: Build a simple script that uploads a file named example.txt to an S3 bucket called my-test-bucket and then downloads it back as downloaded_example.txt.
📋 What You'll Learn
Use the AWS SDK for Python (boto3).
Create a variable for the bucket name my_test_bucket with value 'my-test-bucket'.
Upload the file example.txt to the bucket with the key example.txt.
Download the file from the bucket with the key example.txt and save it locally as downloaded_example.txt.
💡 Why This Matters
🌍 Real World
Uploading and downloading files to cloud storage is common for backups, sharing data, and hosting content.
💼 Career
Cloud engineers and developers often automate file transfers to and from cloud storage services like Amazon S3.
Progress0 / 4 steps
1
Set up AWS S3 client
Import the boto3 library and create an S3 client called s3_client.
AWS
Need a hint?

Use import boto3 and then boto3.client('s3') to create the client.

2
Create bucket name variable
Create a variable called my_test_bucket and set it to the string 'my-test-bucket'.
AWS
Need a hint?

Use a simple assignment like my_test_bucket = 'my-test-bucket'.

3
Upload the file to S3
Use s3_client.upload_file to upload the local file 'example.txt' to the bucket my_test_bucket with the key 'example.txt'.
AWS
Need a hint?

Call s3_client.upload_file('example.txt', my_test_bucket, 'example.txt') to upload.

4
Download the file from S3
Use s3_client.download_file to download the file with key 'example.txt' from the bucket my_test_bucket and save it locally as 'downloaded_example.txt'.
AWS
Need a hint?

Call s3_client.download_file(my_test_bucket, 'example.txt', 'downloaded_example.txt') to download.