static S uploadFileToFileServer(S pathOrURL) { File f = urlToFileOpt(pathOrURL); if (f != null) ret uploadFileToFileServer(f); else if (isURL(pathOrURL)) { File tmp = createTempFile(); afterwards { deleteFile(tmp); } loadBinaryPageToFile(pathOrURL, tmp); ret uploadFileToFileServer(tmp, pathOrURL); } else ret uploadFileToFileServer(newFile(pathOrURL)); } static S uploadFileToFileServer(File f) { ret uploadFileToFileServer(f, f.getName()); } // TODO: optimize static S uploadFileToFileServer(File f, S name) { assertFileExists(f); ret uploadFileToFileServer(loadBinaryFile(f), name); } static S uploadFileToFileServer(byte[] data, S name) { print("Uploading " + l(data) + " bytes (" + quote(name) + ") to file server."); S page = postPage("https://botcompany.de/files/upload", "data", bytesToHex(data), "name", name, '_pass, muricaPassword()); print(page); Matcher m = Pattern.compile("/raw/([0-9]+)").matcher(page); if (!m.find()) fail("File server said: " + page); S url = "https://botcompany.de/files/" + m.group(1); infoBox("Uploaded: " + url); ret url; }