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": "https://developer.github.com/enterprise/2.20/v3/repos/contents/#get-contents"}
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
try:
repo.create_file(file_path, "elastic_backups", bk_object.text, branch="master")
print('creating new file ',file_path)
except:
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')