Created
July 13, 2014 18:28
-
-
Save chriskief/5b07a556378d7f21cc0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from boto.s3.connection import S3Connection | |
connection = S3Connection('aws access key', 'aws secret key') | |
buckets = connection.get_all_buckets() | |
for bucket in buckets: | |
for key in bucket.list(): | |
print('%s' % key) | |
if key.name.endswith('.jpg'): | |
contentType = 'image/jpeg' | |
elif key.name.endswith('.png'): | |
contentType = 'image/png' | |
else: | |
continue | |
key.metadata.update({ | |
'Content-Type': contentType, | |
'Cache-Control': 'max-age=864000' | |
}) | |
key.copy( | |
key.bucket.name, | |
key.name, | |
key.metadata, | |
preserve_acl=True | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment