def upload_file(s3, keyname, filename):
    """ Create a new S3 key with filename contents, return its URL and MD5 hash.
    """
    key = s3.new_key(keyname)
    kwargs = dict(policy='public-read', reduced_redundancy=True)
    key.set_contents_from_filename(filename, **kwargs)
    url = key.generate_url(expires_in=0, query_auth=False, force_http=True)
    return url, key.md5
