|
9 | 9 |
|
10 | 10 |
|
11 | 11 | 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": |
34 | 26 | bucket.put_object(Key=full_key, Body=auto, |
35 | 27 | ACL='public-read') |
| 28 | + else: |
| 29 | + bucket.put_object(Key=full_key, Body=auto, ACL='public-read', |
| 30 | + ContentType=content_type) |
36 | 31 |
|
37 | 32 |
|
38 | 33 | if __name__ == "__main__": |
|
0 commit comments