Created
July 15, 2023 07:30
-
-
Save maskaravivek/f3899e418843af791c5d0c57a496c4bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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