Transpiled version (3872L) is out of date.
1 | // super-short version |
2 | static String uploadData(S pathToDataFile) { |
3 | File file = new File(pathToDataFile); |
4 | ret uploadData(programID(), file.getAbsolutePath(), file); |
5 | } |
6 | |
7 | sS uploadData(File file) { |
8 | ret uploadData(programID(), file.getAbsolutePath(), file); |
9 | } |
10 | |
11 | static String uploadData(String gummipw, String title, File dataFile) ctex { |
12 | return uploadData(gummipw, title, loadBinaryFile(dataFile), false); |
13 | } |
14 | |
15 | static String uploadDataSuperHigh(String gummipw, String title, File dataFile) ctex { |
16 | return uploadData(gummipw, title, loadBinaryFile(dataFile), true); |
17 | } |
18 | |
19 | static String uploadData(String gummipw, String title, byte[] data) throws IOException { |
20 | return uploadData(gummipw, title, data, false); |
21 | } |
22 | |
23 | static String uploadData(String gummipw, String title, byte[] data, boolean superhigh) throws IOException { |
24 | if (gummipw == null || gummipw.length() == 0) |
25 | throw new RuntimeException("Need gummi password."); |
26 | |
27 | System.out.println("Uploading:"); |
28 | System.out.println(" gummipw: " + gummipw); |
29 | System.out.println(" " + title); |
30 | int displayLength = 40; |
31 | System.out.println(" " + data.length + " bytes of data"); |
32 | |
33 | URL url = new URL(tb_mainServer() + "/tb-int/add_snippet.php"); |
34 | String postData = |
35 | "gummipw=" + URLEncoder.encode(unnull(gummipw), "UTF-8") |
36 | + "&blob=" + URLEncoder.encode(base64encode(data), "UTF-8") |
37 | + "&name=" + URLEncoder.encode(unnull(title), "UTF-8") |
38 | + "&type=" + 37 /* SN_DATA */ |
39 | + "&" + (superhigh ? "superhigh" : "high") + "=1&public=1"; |
40 | System.out.println("Post data length: " + postData.length()); |
41 | |
42 | String contents = doPost(postData, url.openConnection(), url); |
43 | System.out.println(contents); |
44 | |
45 | if (isInteger(contents)) { |
46 | long id = parseSnippetID(contents); |
47 | System.out.println("=> #" + id); |
48 | return "#" + id; |
49 | } else |
50 | throw new RuntimeException("Server error: " + contents); |
51 | } |
Began life as a copy of #1000741
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, kmhbujppghqa, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, snaazhdonpnp, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1000754 |
Snippet name: | uploadData function |
Eternal ID of this version: | #1000754/4 |
Text MD5: | 26eaeb90d771813c7e8f62b07d20090b |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-02 16:27:53 |
Source code size: | 1916 bytes / 51 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 864 / 1196 |
Version history: | 3 change(s) |
Referenced in: | [show references] |