diff --git a/src/main/java/org/kohsuke/github/GHContent.java b/src/main/java/org/kohsuke/github/GHContent.java index 443dd5918..dbc56a953 100644 --- a/src/main/java/org/kohsuke/github/GHContent.java +++ b/src/main/java/org/kohsuke/github/GHContent.java @@ -129,11 +129,19 @@ public class GHContent { } public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException { - return update(newContent, commitMessage, null); + return update(newContent.getBytes(), commitMessage, null); } - public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException { - String encodedContent = DatatypeConverter.printBase64Binary(newContent.getBytes()); + public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException { + return update(newContent.getBytes(), commitMessage, branch); + } + + public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException { + return update(newContentBytes, commitMessage, null); + } + + public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage, String branch) throws IOException { + String encodedContent = DatatypeConverter.printBase64Binary(newContentBytes); Requester requester = new Requester(owner.root) .with("path", path) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 4e3441166..740ae2122 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -939,15 +939,24 @@ public class GHRepository { return getFileContent("readme"); } - public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException { - return createContent(content, commitMessage, path, null); + + public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException { + return createContent(content.getBytes(), commitMessage, path, null); + } + + public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException { + return createContent(content.getBytes(), commitMessage, path, branch); + } + + public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path) throws IOException { + return createContent(contentBytes, commitMessage, path, null); } - public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException { + public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path, String branch) throws IOException { Requester requester = new Requester(root) .with("path", path) .with("message", commitMessage) - .with("content", DatatypeConverter.printBase64Binary(content.getBytes())) + .with("content", DatatypeConverter.printBase64Binary(contentBytes)) .method("PUT"); if (branch != null) {