How to Upload files to s3 using Python||AWS

In this article, I will be showing you how to upload files from your computer to AWS S3 Bucket using Python...

python || AWS
Photo by Ilya Pavlov on Unsplash

Lets get started

Before starting this article I hope you have AWS account and python installed in your machine that’s what we need to do this

To complete this task we need :

  1. ACCESS KEY (which can be found/created using IAM in AWS)

import os

import boto3

from botocore.exceptions import ClientError

ACCESS_KEY = ‘your_access_key’

SECRET_KEY = ‘your_secret_key’

bucket_name = ‘testingkit’

client_s3 = boto3.client(




file_path = os.path.join(os.getcwd(),)

for file in os.listdir(file_path):

if not file.startswith(‘~’):



os.path.join(file_path, file),bucket_name,file


except ClientError as CE:

print(‘invalid credentials ‘ + CE)

except Exception as e:


In this above code use your ACCESS KEY & SECRET KEY and it will upload your all the files from your present working directory to s3 Bucket to import files from machine I’ve Imported OS module,

and BOTO3 which is a AWS SDK which will help us to connect to s3 and upload our files from machine to Bucket, that’s what we want to do.




Software Engineer, Laravel || php, Python || AWS

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Solve long, then solve fast.

✅ Validation for Airdrop “1000 $HOPE to max 1000 wallets”

Count number of times a value occurs in a dataframe

Not Enough Real Devices for Debugging? AppGallery Connect Cloud Debugging Has Got Your Back!

An outside view on primitives in Rust

Emergent Behavior to Supercharge your Workplace

Alnair Finance , Upcoming events #2

How to Build and Test your Unity Game

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Software Engineer, Laravel || php, Python || AWS

More from Medium

Automating Google Drive Uploads With Google Drive API & cURL

Docker — A Beginner’s Guide to Understanding and Building Docker Images

Django rest framework API on Azure web service with cx_Oracle

Relational database (MySql)