It seems go-github supports creating a blob and specifying its encoding to be "base64", but if I choose to use TreeEntry to create a tree, there is no way I can specify if this TreeEntry's encoding type - https://developer.github.com/v3/git/trees/#create-a-tree. Is there a way that when adding a "blob" type TreeEntry I can also specify that the content of this blob is base64 encoded? Thanks!
And to add a bit context to why I run into this issue, I was trying to create a commit which contains ".jar" files, and found out that reading the .jar files into bytes (using ioutiles.Readfile()) and then convert to string and put it into a TreeEntry - this actually messes up the .jar files content when it gets uploaded to my github repo (maybe I am doing something apparently wrong?).
I've read through the documentation at the link you have provided, and it is not obvious to me how to upload binary data like you wish to do via the GitHub API.
Can you please send an email to [email protected] and ask them how to send binary data via this API, then report back here with the response?
Thank you, @zhuzeng!
Thanks @gmlewis for the prompt response! Yes I also didn't find documents mentioned about this but assuming it should be able to do so that's why I have been trying different approaches. I will send an email to [email protected] and post the answer back once I got it.
Just a quick update, I have sent out an email to [email protected] and in the meantime I've tried the following and it works for my .jar files:
The above works. But as it shows, you will need to create individual new blobs for your binary files, and then use their SHA in the tree entries to create the commit. Ideally I think the TreeEntry should have a "Encoding" (just like Blob type does) field and automatically does that.
Excellent! I'm glad you got it to work, @zhuzeng!
If you come up with a good API to support doing this as a method in this repo, feel free to submit a PR and we can consider adding it. I would think that you can make the base64 encoding optional and the default would be to just send the utf-8 contents unmodified as a string.
@gauntface will also need to sign off on this new API and PR, so I'll mention him here so he has a heads-up on what might be coming. :smile:
Thanks @gmlewis . I will try to make a PR when I get time :)
Hi, I was wondering if anyone is actively working on this issue. I'm looking for somewhere I can contribute, so if I can help out somehow with this please let me know. Thanks.
If you are just starting out, this issue is rather complex and I would not recommend it.
This is a specific challenge that @zhuzeng had and since there have been no other comments on the issue, we'll probably give this one a little more time but then close it due to inactivity.
Feel free to peruse the other issues, and check out our CONTRIBUTING.md guide for getting started. Thank you for your interest!
Yeah I thought this might be complicated. I'll check out the guide and also keep checking back for recommended "new contributor" issues. Thanks.
Sorry @gmlewis that I didn't really get time to make the PR, and as you mentioned this issue is rather complex. Since I opened this issue at the first place, and I have a workaround, I will close this issue for now.
Most helpful comment
Just a quick update, I have sent out an email to [email protected] and in the meantime I've tried the following and it works for my .jar files:
The above works. But as it shows, you will need to create individual new blobs for your binary files, and then use their SHA in the tree entries to create the commit. Ideally I think the TreeEntry should have a "Encoding" (just like Blob type does) field and automatically does that.