Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 2a99407

Browse files
Merge pull request #502 from PythonicBoat/main
AWS s3 uploader
2 parents 6b44ed9 + f24a8ec commit 2a99407

4 files changed

Lines changed: 78 additions & 30 deletions

File tree

README.md

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -867,14 +867,21 @@
867867
<sub><b>Jefferson Bublitz</b></sub>
868868
</a>
869869
</td>
870+
<td align="center">
871+
<a href="https://github.com/PythonicBoat">
872+
<img src="https://avatars.githubusercontent.com/u/68675629?v=4" width="100;" alt="PythonicBoat"/>
873+
<br />
874+
<sub><b>Yashvardhan Singh</b></sub>
875+
</a>
876+
</td></tr>
877+
<tr>
870878
<td align="center">
871879
<a href="https://github.com/shriyansnaik">
872880
<img src="https://avatars.githubusercontent.com/u/66057990?v=4" width="100;" alt="shriyansnaik"/>
873881
<br />
874882
<sub><b>Shriyans Naik</b></sub>
875883
</a>
876-
</td></tr>
877-
<tr>
884+
</td>
878885
<td align="center">
879886
<a href="https://github.com/nayan2306">
880887
<img src="https://avatars.githubusercontent.com/u/79744453?v=4" width="100;" alt="nayan2306"/>
@@ -889,13 +896,6 @@
889896
<sub><b>Oluwatomilola</b></sub>
890897
</a>
891898
</td>
892-
<td align="center">
893-
<a href="https://github.com/PythonicBoat">
894-
<img src="https://avatars.githubusercontent.com/u/68675629?v=4" width="100;" alt="PythonicBoat"/>
895-
<br />
896-
<sub><b>Yashvardhan Singh</b></sub>
897-
</a>
898-
</td>
899899
<td align="center">
900900
<a href="https://github.com/herepete">
901901
<img src="https://avatars.githubusercontent.com/u/40490116?v=4" width="100;" alt="herepete"/>
@@ -1649,6 +1649,13 @@
16491649
</a>
16501650
</td></tr>
16511651
<tr>
1652+
<td align="center">
1653+
<a href="https://github.com/pranavdasan">
1654+
<img src="https://avatars.githubusercontent.com/u/62214486?v=4" width="100;" alt="pranavdasan"/>
1655+
<br />
1656+
<sub><b>Pranav Dasan</b></sub>
1657+
</a>
1658+
</td>
16521659
<td align="center">
16531660
<a href="https://github.com/Pratham-H-S">
16541661
<img src="https://avatars.githubusercontent.com/u/126776410?v=4" width="100;" alt="Pratham-H-S"/>
@@ -1683,15 +1690,15 @@
16831690
<br />
16841691
<sub><b>RishiPastor05</b></sub>
16851692
</a>
1686-
</td>
1693+
</td></tr>
1694+
<tr>
16871695
<td align="center">
16881696
<a href="https://github.com/Surya-29">
16891697
<img src="https://avatars.githubusercontent.com/u/75674235?v=4" width="100;" alt="Surya-29"/>
16901698
<br />
16911699
<sub><b>Surya Narayan</b></sub>
16921700
</a>
1693-
</td></tr>
1694-
<tr>
1701+
</td>
16951702
<td align="center">
16961703
<a href="https://github.com/Sai-Uttej-R">
16971704
<img src="https://avatars.githubusercontent.com/u/95533451?v=4" width="100;" alt="Sai-Uttej-R"/>
@@ -1726,15 +1733,15 @@
17261733
<br />
17271734
<sub><b>Suliman Sagindykov</b></sub>
17281735
</a>
1729-
</td>
1736+
</td></tr>
1737+
<tr>
17301738
<td align="center">
17311739
<a href="https://github.com/sumitbaroniya">
17321740
<img src="https://avatars.githubusercontent.com/u/75536160?v=4" width="100;" alt="sumitbaroniya"/>
17331741
<br />
17341742
<sub><b>Sumit Baroniya</b></sub>
17351743
</a>
1736-
</td></tr>
1737-
<tr>
1744+
</td>
17381745
<td align="center">
17391746
<a href="https://github.com/swapnadeepmohapatra">
17401747
<img src="https://avatars.githubusercontent.com/u/41564532?v=4" width="100;" alt="swapnadeepmohapatra"/>
@@ -1769,15 +1776,15 @@
17691776
<br />
17701777
<sub><b>Yash Tariyal</b></sub>
17711778
</a>
1772-
</td>
1779+
</td></tr>
1780+
<tr>
17731781
<td align="center">
17741782
<a href="https://github.com/Ylavish64">
17751783
<img src="https://avatars.githubusercontent.com/u/105187742?v=4" width="100;" alt="Ylavish64"/>
17761784
<br />
17771785
<sub><b>Ylavish64</b></sub>
17781786
</a>
1779-
</td></tr>
1780-
<tr>
1787+
</td>
17811788
<td align="center">
17821789
<a href="https://github.com/yogesh78026">
17831790
<img src="https://avatars.githubusercontent.com/u/77293859?v=4" width="100;" alt="yogesh78026"/>
@@ -1812,15 +1819,15 @@
18121819
<br />
18131820
<sub><b>Emmanuel Ogu</b></sub>
18141821
</a>
1815-
</td>
1822+
</td></tr>
1823+
<tr>
18161824
<td align="center">
18171825
<a href="https://github.com/d-coder111">
18181826
<img src="https://avatars.githubusercontent.com/u/82580017?v=4" width="100;" alt="d-coder111"/>
18191827
<br />
18201828
<sub><b>D-coder111</b></sub>
18211829
</a>
1822-
</td></tr>
1823-
<tr>
1830+
</td>
18241831
<td align="center">
18251832
<a href="https://github.com/dab07">
18261833
<img src="https://avatars.githubusercontent.com/u/78215681?v=4" width="100;" alt="dab07"/>
@@ -1855,15 +1862,15 @@
18551862
<br />
18561863
<sub><b>Dhruv Jagdish</b></sub>
18571864
</a>
1858-
</td>
1865+
</td></tr>
1866+
<tr>
18591867
<td align="center">
18601868
<a href="https://github.com/jonascarvalh">
18611869
<img src="https://avatars.githubusercontent.com/u/79672134?v=4" width="100;" alt="jonascarvalh"/>
18621870
<br />
18631871
<sub><b>Jonas Carvalho</b></sub>
18641872
</a>
1865-
</td></tr>
1866-
<tr>
1873+
</td>
18671874
<td align="center">
18681875
<a href="https://github.com/kodingkin">
18691876
<img src="https://avatars.githubusercontent.com/u/125667216?v=4" width="100;" alt="kodingkin"/>
@@ -1898,15 +1905,15 @@
18981905
<br />
18991906
<sub><b>Myudak</b></sub>
19001907
</a>
1901-
</td>
1908+
</td></tr>
1909+
<tr>
19021910
<td align="center">
19031911
<a href="https://github.com/NebulaAnish">
19041912
<img src="https://avatars.githubusercontent.com/u/50112251?v=4" width="100;" alt="NebulaAnish"/>
19051913
<br />
19061914
<sub><b>NebulaAnish</b></sub>
19071915
</a>
1908-
</td></tr>
1909-
<tr>
1916+
</td>
19101917
<td align="center">
19111918
<a href="https://github.com/pingavisek">
19121919
<img src="https://avatars.githubusercontent.com/u/57057681?v=4" width="100;" alt="pingavisek"/>
@@ -1941,15 +1948,15 @@
19411948
<br />
19421949
<sub><b>Shreya Rathore</b></sub>
19431950
</a>
1944-
</td>
1951+
</td></tr>
1952+
<tr>
19451953
<td align="center">
19461954
<a href="https://github.com/ta-brook">
19471955
<img src="https://avatars.githubusercontent.com/u/85091595?v=4" width="100;" alt="ta-brook"/>
19481956
<br />
19491957
<sub><b>Tanawat Jirawttanakul</b></sub>
19501958
</a>
1951-
</td></tr>
1952-
<tr>
1959+
</td>
19531960
<td align="center">
19541961
<a href="https://github.com/LionLostInCode">
19551962
<img src="https://avatars.githubusercontent.com/u/133058949?v=4" width="100;" alt="LionLostInCode"/>

projects/AWS_s3_upload/main.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import boto3
2+
from botocore.exceptions import NoCredentialsError
3+
4+
ACCESS_KEY = ''
5+
SECRET_KEY = ''
6+
LOCAL_FILE = 'local_file_name'
7+
BUCKET_NAME = 'bucket_name'
8+
S3_FILE_NAME = 'file_name_on_s3'
9+
10+
def upload_to_s3(local_file, bucket, s3_file):
11+
## This function is responsible for uploading the file into the S3 bucket using the specified credentials.
12+
s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,
13+
aws_secret_access_key=SECRET_KEY)
14+
try:
15+
s3.upload_file(local_file, bucket, s3_file)
16+
print("Upload Successful")
17+
return True
18+
except FileNotFoundError:
19+
print("The file was not found")
20+
return False
21+
except NoCredentialsError:
22+
print("Credentials not available")
23+
return False
24+
25+
26+
result = upload_to_s3(LOCAL_FILE, BUCKET_NAME, S3_FILE_NAME)

projects/AWS_s3_upload/readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
## Simple Python script for AWS S3 file upload.
3+
4+
### Prerequisites
5+
boto3 (pip install boto3) <br />
6+
7+
### How to run the script
8+
- Specify both ACCESS_KEY and SECRET_KEY. You can get them both on your AWS account in "My Security Credentials" section. <br />
9+
- Specify the local file name, bucket name and the name that you want the file to have inside s3 bucket using LOCAL_FILE, BUCKET_NAME and S3_FILE_NAME variables. <br />
10+
- Run "python main.py" <br />
11+
12+
### Author Name
13+
Yashvardhan Singh https://github.com/pythonicboat
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
boto3==1.20.4
2+
botocore==1.23.4

0 commit comments

Comments
 (0)