Skip to content

Commit e247bbd

Browse files
committed
clean up update script
1 parent 65235ff commit e247bbd

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

update_s3.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,25 @@
99

1010

1111
def upload_with_content_type(file, full_key, auto):
12-
if ".html" in file:
13-
print("uploading \"{}\" as html".format(full_key))
14-
bucket.put_object(Key=full_key, Body=auto, ACL='public-read',
15-
ContentType="text/html")
16-
elif ".css" in file:
17-
print("uploading \"{}\" as css".format(full_key))
18-
bucket.put_object(Key=full_key, Body=auto, ACL='public-read',
19-
ContentType="text/css")
20-
elif ".jpg" in file:
21-
print("uploading \"{}\" as jpeg".format(full_key))
22-
bucket.put_object(Key=full_key, Body=auto, ACL='public-read',
23-
ContentType="image/jpeg")
24-
elif ".png" in file:
25-
print("uploading \"{}\" as png".format(full_key))
26-
bucket.put_object(Key=full_key, Body=auto, ACL='public-read',
27-
ContentType="image/png")
28-
elif ".xml" in file:
29-
print("uploading \"{}\" as xml".format(full_key))
30-
bucket.put_object(Key=full_key, Body=auto, ACL='public-read',
31-
ContentType="application/xml")
32-
else:
33-
print("uploading \"{}\"".format(full_key))
12+
content_type = "default"
13+
if file.endswith(".html"):
14+
content_type = "text/html"
15+
elif file.endswith(".css"):
16+
content_type = "text/css"
17+
elif file.endswith(".jpg"):
18+
content_type = "image/jpeg"
19+
elif file.endswith(".png"):
20+
content_type = "image/png"
21+
elif file.endswith(".xml"):
22+
content_type = "application/xml"
23+
24+
print("uploading \"{}\" as {}".format(full_key, content_type))
25+
if content_type is "default":
3426
bucket.put_object(Key=full_key, Body=auto,
3527
ACL='public-read')
28+
else:
29+
bucket.put_object(Key=full_key, Body=auto, ACL='public-read',
30+
ContentType=content_type)
3631

3732

3833
if __name__ == "__main__":

0 commit comments

Comments
 (0)