/** * Because github relies on SNI (http://en.wikipedia.org/wiki/Server_Name_Indication) this method will only work on * Java 7 or greater. Options for fixing this for earlier JVMs can be found here * http://stackoverflow.com/questions/12361090/server-name-indication-sni-on-java but involve more complicated * handling of the HTTP requests to github's API. * * @throws IOException */ public GHAsset uploadAsset(File file, 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()); return builder.contentType(contentType) .with(new FileInputStream(file)) .to(url, GHAsset.class).wrap(this); }
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(), filename); return builder.contentType(contentType) .with(stream) .to(url, GHAsset.class).wrap(this); }
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(), filename); return builder.contentType(contentType) .with(stream) .to(url, GHAsset.class).wrap(this); }