diff --git a/src/main/java/org/kohsuke/github/GHRelease.java b/src/main/java/org/kohsuke/github/GHRelease.java index a299add2c5..d49c0a2890 100644 --- a/src/main/java/org/kohsuke/github/GHRelease.java +++ b/src/main/java/org/kohsuke/github/GHRelease.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.Arrays; import java.util.Date; @@ -125,12 +126,16 @@ static GHRelease[] wrap(GHRelease[] releases, GHRepository owner) { * handling of the HTTP requests to github's API. */ public GHAsset uploadAsset(File file, String contentType) throws IOException { + return uploadAsset(file.getName(), new FileInputStream(file), contentType); + } + + public GHAsset uploadAsset(String filename, InputStream stream, String contentType) throws IOException { Requester builder = new Requester(owner.root); String url = format("https://uploads.github.com%s/releases/%d/assets?name=%s", - owner.getApiTailUrl(""), getId(), file.getName()); + owner.getApiTailUrl(""), getId(), filename); return builder.contentType(contentType) - .with(new FileInputStream(file)) + .with(stream) .to(url, GHAsset.class).wrap(this); }