code: def upload_file_boto(fname, remote_fname, mditems=None):
      
      r_fname = objectstore.parse_remote(remote_fname)
      conn = objectstore.connect(remote_fname)
      bucket = conn.lookup(r_fname.bucket)
      if not bucket:
          bucket = conn.create_bucket(r_fname.bucket, location=objectstore.get_region(remote_fname))
      key = bucket.get_key(r_fname.key, validate=False)
      if mditems is None:
          mditems = {}
      if "x-amz-server-side-encryption" not in mditems:
          mditems["x-amz-server-side-encryption"] = "AES256"
      for name, val in mditems.items():
          key.set_metadata(name, val)
      key.set_contents_from_filename(fname, encrypt_key=True)
docs: Upload a file using boto instead of external tools.