def _upload(awskey, awssecret, filename, bucketname, keyname, acl): """ Uploads a file to S3 """ try: conn = S3Connection(awskey, awssecret) bucket = conn.get_bucket(bucketname) key = bucket.new_key(keyname) #key.set_metadata("ETag", _hasher(filename)) key.set_metadata("Cache-Control", "max-age=31104000") key.set_contents_from_filename(filename) key.set_acl(acl) except S3ResponseError as exc: if exc.status == 403: sys.exit('Error: Please check your Amazon credentials!') elif exc.status == 404: sys.exit('Error: Your bucket does not exist (yet)') else: print (filename, ' Upload successful!')