import click


def create_binarycontent(api, msg):
    """ Create a binary content item and set the foreign key to new ID
    """
    click.echo("Uploading binary file %(binary_content)s." % msg)
    files = {'content': click.open_file(msg["binary_content"])}
    binary_content = api.create_binarycontent(files)
    # update the ref to a foreign key now
    msg["binary_content"] = binary_content["id"]
    return msg