I have been getting errors trying to upload image files to my GitHub repo using GitHub API.
I am using JavaScript to perform this function, I already did it for updating text contents on my repo using the same programmatic method with my Personal Access Token as the auth key. My process went successful for updating texts but uploading images has been a problem.
Since images is a binary, and would require encoding and decoding properly to be able to be uploaded to my github.
I am basically looking for a source code sample that would help me perform this function.
Here are the steps: Step 1: I have an html form that collects file inputs of up to 3.
Step 2: I have created a repo on my GitHub which have an "images" folder as the path the uploaded form input files will be pushed programmatically using GitHub API.
Step 3: I'm using JavaScript, (if applicable, I used Octokit library to do the same for texts) to first get the document.getElementsById("").files[0] of each of my form inputs.
Step 4: I had write the necessary code in JavaScript to push those images to the "images/" folder on my repo handling the base64 encoding and extraction to give me the original image on my repo images folder after the form submit button (eventListener) is clicked.
I only had the text content updating with GitHub figured out but the images have been a big challenge to me.
So the question is, can someone help me with a typical source code that gets my images and send them to the images Folger on my repo using JavaScript, Github API, and any other client-side supported mechanism like "ajax"
I found close help here but I want be more informed on my need.
I tried using GitHub API directly to handle the blobs, tree and Sha of my function but it went really wrong as my console had said.
There were problem with the way my function reads the file and could not process it.
My console gave a 500 error (unprocessed content) and few other trials be worse.
I just need to be able to get my form input uploaded files to be pushed to my repository in the images folder path.