Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maskaravivek/f3899e418843af791c5d0c57a496c4bf to your computer and use it in GitHub Desktop.
Save maskaravivek/f3899e418843af791c5d0c57a496c4bf to your computer and use it in GitHub Desktop.
const createGithubFileBlob = async (
githubAccessToken,
repoFullName,
content,
encoding = "utf-8"
) => {
const blobResp = await fetch(
`https://api.github.com/repos/${repoFullName}/git/blobs`,
{
method: "POST",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${githubAccessToken}`,
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({
content: content,
encoding: encoding,
}),
}
);
const response = await blobResp.json();
return response.sha;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment