-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathputimages.py
More file actions
23 lines (21 loc) · 761 Bytes
/
putimages.py
File metadata and controls
23 lines (21 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import boto3
import os
s3 = boto3.resource('s3')
image_directory = '/Users/atchudhansreekanth/Desktop/images'
metadata = {
'image1.jpg': 'Elon Musk',
'image2.jpg': 'Elon Musk',
'image3.jpg': 'Bill Gates',
'image4.jpg': 'Bill Gates',
'image5.jpg': 'Sundar Pichai',
'image6.jpg': 'Sundar Pichai'
}
for filename in os.listdir(image_directory):
if filename.endswith(('.jpg', '.jpeg', '.png')):
file_path = os.path.join(image_directory, filename)
with open(file_path, 'rb') as file:
s3_object = s3.Object('famouspersons-images-atchudhan', 'index/' + filename)
ret = s3_object.put(
Body=file,
Metadata={'FullName': metadata.get(filename, 'Unknown')}
)