Skip to content

Instantly share code, notes, and snippets.

Created January 22, 2021 22:03
What would you like to do?
send extra headers to s3
#!/usr/bin/env python
from argparse import ArgumentParser
import sys
import json
import boto3
parser = ArgumentParser()
parser.add_argument('bucket', help='Bucket to make')
parser.add_argument('-H', '--header', action='append', default=[],
help='Extra headers')
def main():
opts = parser.parse_args()
conn = boto3.client('s3', endpoint_url='http://saio:8080',
def extra_headers(params, **kwargs):
for header_arg in opts.header:
key, value = (x.strip() for x in header_arg.split(':'))
params['headers'][key] = value'before-call.s3.CreateBucket', extra_headers)
resp = conn.create_bucket(Bucket=opts.bucket)
print(json.dumps(resp, indent=2))
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment