def METHOD_NAME(filepath):
    """Generate url for DatasetFile."""
    try:
        project = project_context.project
        if not project:
            return
    except ValueError:
        from renku.core.migration.models.v9 import Project
        metadata_path = project_context.metadata_path.joinpath(OLD_METADATA_PATH)
        project = Project.from_yaml(metadata_path)
        project_id = urlparse(project._id)
    else:
        project_id = urlparse(project.id)
    filepath = quote(filepath, safe="/")
    path = posixpath.join(project_id.path, "files", "blob", filepath)
    project_id = project_id._replace(path=path)
    return project_id.geturl()