!752 lib 1004792 // commons codec import org.apache.commons.codec.net.URLCodec; static boolean test; p { S name = args[0]; // put file name here if (args.length > 1 && args[1].equals("test")) test = true; name = new File(name).getAbsolutePath(); byte[] data = loadBinaryFile(name); if (data == null) print("File not found: " + name); else if (test) print(binaryUrlencode(data)); else uploadData("data-uploader " + programID(), "Data file " + name + " from " + computerID(), data, false); } static String uploadData(String gummipw, String title, byte[] data, boolean superhigh) throws IOException { if (gummipw == null || gummipw.length() == 0) throw new RuntimeException("Need gummi password."); System.out.println("Uploading:"); System.out.println(" gummipw: " + gummipw); System.out.println(" " + title); int displayLength = 40; System.out.println(" " + data.length + " bytes of data"); URL url = new URL("http://tinybrain.de:8080/tb-int/add_snippet.php"); S base = base64encode(data); print("Base-encoded => " + l(base)); data = null; S encoded = new URLCodec().encode(base, "UTF-8"); base = null; print("URL-encoded => " + l(encoded)); String postData = "gummipw=" + URLEncoder.encode(unnull(gummipw), "UTF-8") + "&blob=" + encoded + "&name=" + URLEncoder.encode(unnull(title), "UTF-8") + "&type=" + 37 /* SN_DATA */ + "&" + (superhigh ? "superhigh" : "high") + "=1&public=1"; System.out.println("Post data length: " + postData.length()); String contents = doPost(postData, url.openConnection(), url); System.out.println(contents); if (isInteger(contents)) { long id = parseSnippetID(contents); System.out.println("=> #" + id); return "#" + id; } else throw new RuntimeException("Server error: " + contents); }