Skip to content

Commit 3a70028

Browse files
author
Miguel Wychovaniec
committed
S3 file upload project Python-World#449
1 parent 4bb9903 commit 3a70028

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

projects/S3_File_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)
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.
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.
10+
Run "python main.py"
11+
12+
###Author Name
13+
Miguel Wychovaniec - https://github.com/miguelwy

projects/S3_File_Upload/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
ACCESS_KEY = 'XXXXXXXXXXXXXXXXX'
55
SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
6+
LOCAL_FILE = 'local_file_name'
7+
BUCKET_NAME = 'bucket_name'
8+
S3_FILE_NAME = 'file_name_on_s3'
69

710
def upload_to_s3(local_file, bucket, s3_file):
811
s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,
@@ -19,4 +22,4 @@ def upload_to_s3(local_file, bucket, s3_file):
1922
return False
2023

2124

22-
result = upload_to_s3('local_file_name', 'bucket_name', 'file_name_on_s3')
25+
result = upload_to_s3(LOCAL_FILE, BUCKET_NAME, S3_FILE_NAME)

0 commit comments

Comments
 (0)