Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1000566 - ntUpload

JavaX fragment (include)

static S ntUpload(S title, S text) {
  ret ntUpload(programID(), title, text);
}

static String ntUpload(String gummipw, String title, String text) {
  ret ntUpload(gummipw, title, text, "");
}

static String ntUpload(String gummipw, String title, String text, String comment) ctex {
  if (gummipw == null || gummipw.length() == 0)
    throw new RuntimeException("Need gummi password.");
    
  System.out.println("Uploading:");
  System.out.println("  " + gummipw + " (" + text.length() + " chars)");
  System.out.println("  " + title);
  int displayLength = 40;
  System.out.println("  " + (text.length() > displayLength ? quote(text.substring(0, displayLength)) + " [...]" : quote(text)));

  URL url = new URL("http://tinybrain.de:8080/nt-int/add_snippet.php");
  String postData = makePostData(
    "gummipw", gummipw,
    "text", text,
    "title", title,
    "comment", comment);

  String contents = doPost(postData, url.openConnection(), url);

  if (isInteger(contents)) {
    long id = parseSnippetID(contents);
    System.out.println("=> #" + id);
    return "#" + id;
  } else
    throw new RuntimeException("Server error: " + contents);
}

download  show line numbers  debug dex   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1000566
Snippet name: ntUpload
Eternal ID of this version: #1000566/2
Text MD5: 0c278117b80cd06d3fc1f6a3f7694fad
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-03 17:24:03
Source code size: 1185 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 471 / 848
Version history: 1 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1000566 & http://1000566.tinybrain.de