Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github API, how to use blobs

In order to understand how blobs work in Github API, I tried to create a blob with showing in the below poster, I got 201 created in the response, but in my github repository I say nothing about this blob. I don't understand how the blob works here, my expected function of the blob is that it allows me to push a file to the repository, basically what I want to achieve is use github API to push files to the repository, how to do this with the blob API?

enter image description here

like image 868
msn Avatar asked Oct 19 '25 04:10

msn


1 Answers

my expected function of the blob is that it allows me to push a file to the repository

Git doesn't ever push files. It pushes commits. And Git blobs are pretty low-level.

I think you're using the wrong API endpoint. The contents endpoint lets you create files:

Create a file

This method creates a new file in a repository

PUT /repos/:owner/:repo/contents/:path

Parameters

  • path (string, required): The content path
  • message (string, required): The commit message
  • content (string, required): The new file content, Base64 encoded
  • branch (string): the branch name. Default: the repository’s default branch (usually master)

Optional Parameters

You can provide an additional committer parameter, which is an object containing information about the committer. Or, you can provide an author parameter, which is an object containing information about the author.

like image 102
Chris Avatar answered Oct 21 '25 08:10

Chris