def upload(client, wid, file, **kwargs):
    """ Upload a file to a workspace.

    This function calls the Quetzal API endpoint to upload a file into a
    workspace.

    Parameters
    ----------
    client: quetzal.client.Client
        Client object that will be used for the Quetzal API operation.
    wid: int
        Workspace identifier.
    file: file-like object
        A file object, like the returned objects of ``io.Open``. It must have a
        name attribute (used to set the filename metadata) and a read method.

    Returns
    -------
    file_details: quetzal.openapi_client.models.BaseMetadata
        Uploaded file details.

    Raises
    ------
    quetzal.client.exceptions.QuetzalAPIException
        When the API returns an error.
    urllib3.exceptions.RequestError
        When there was a problem connecting to the server.

    """
    if not hasattr(file, 'read') or not hasattr(file, 'name'):
        raise ValueError('file must have a read method and name attribute.')
    file_details = client.workspace_file_create(wid, content=file.name, **
        kwargs)
    return file_details
