Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 5121fe1

Browse files
author
mendeza
committed
Added binary content support.
1 parent af3099c commit 5121fe1

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/main/java/org/kohsuke/github/GHContent.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,19 @@ protected void wrapUp(GHContent[] page) {
129129
}
130130

131131
public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException {
132-
return update(newContent, commitMessage, null);
132+
return update(newContent.getBytes(), commitMessage, null);
133133
}
134134

135-
public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException {
136-
String encodedContent = DatatypeConverter.printBase64Binary(newContent.getBytes());
135+
public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException {
136+
return update(newContent.getBytes(), commitMessage, branch);
137+
}
138+
139+
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException {
140+
return update(newContentBytes, commitMessage, null);
141+
}
142+
143+
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch) throws IOException {
144+
String encodedContent = DatatypeConverter.printBase64Binary(newContentBytes);
137145

138146
Requester requester = new Requester(owner.root)
139147
.with("path", path)

src/main/java/org/kohsuke/github/GHRepository.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -939,15 +939,24 @@ public GHContent getReadme() throws Exception {
939939
return getFileContent("readme");
940940
}
941941

942-
public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException {
943-
return createContent(content, commitMessage, path, null);
942+
943+
public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException {
944+
return createContent(content.getBytes(), commitMessage, path, null);
945+
}
946+
947+
public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException {
948+
return createContent(content.getBytes(), commitMessage, path, branch);
949+
}
950+
951+
public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path) throws IOException {
952+
return createContent(contentBytes, commitMessage, path, null);
944953
}
945954

946-
public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException {
955+
public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path, String branch) throws IOException {
947956
Requester requester = new Requester(root)
948957
.with("path", path)
949958
.with("message", commitMessage)
950-
.with("content", DatatypeConverter.printBase64Binary(content.getBytes()))
959+
.with("content", DatatypeConverter.printBase64Binary(contentBytes))
951960
.method("PUT");
952961

953962
if (branch != null) {

0 commit comments

Comments
 (0)