PyGitHub - Error 403 {"message": "This API returns blobs up to 1 MB in size

I am working on a Python script to automatically create files on Github and if they exist, update them. I am using the module PyGithub with the logic below.

The problem I have is that when I try to update a file that is bigger that 1Mb, I get:

github.GithubException.GithubException: 403 {"message": "This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size.", "errors": [{"resource": "Blob", "field": "data", "code": "too_large"}], "documentation_url": "

I've tried deleting the files and recreating them but I understand that just the fact of reading the file triggers the error. I've tried several option but nothing works.

I am stuck. Thanks for the help

    repo.create_file(file_path, "elastic_backups", bk_object.text, branch="master")
    print('creating new file ',file_path)
    contents = repo.get_contents(file_path, ref="master")
    repo.update_file(contents.path, "updated elastic backup", bk_object.text, contents.sha, branch="master")
    print(file_path, ' UPDATED')

Relevant tags