/** * 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. */ public GHAsset uploadAsset(File file, String contentType) throws IOException { FileInputStream s = new FileInputStream(file); try { return uploadAsset(file.getName(), s, contentType); } finally { s.close(); } }
/** * 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. */ public GHAsset uploadAsset(File file, String contentType) throws IOException { FileInputStream s = new FileInputStream(file); try { return uploadAsset(file.getName(), s, contentType); } finally { s.close(); } }
private void uploadAsset(GHRelease release, File asset) throws IOException { getLog().info("Processing asset "+asset.getPath()); List<GHAsset> existingAssets = release.getAssets(); for ( GHAsset a : existingAssets ){ if (a.getName().equals( asset.getName() )){ if(overwriteArtifact) { getLog().info(" Deleting existing asset"); a.delete(); } else { getLog().warn("Asset "+asset.getName()+" already exists. Skipping"); return; } } } getLog().info(" Upload asset"); // for some reason this doesn't work currently release.uploadAsset(asset, "application/zip"); }