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

25
LINES

< > TinyBrain | #1008031 - loadDataSnippetToFile

JavaX fragment (include)

static File loadDataSnippetToFile(S snippetID) ctex {
  snippetID = fsI(snippetID);
  File f = DiskSnippetCache_file(parseSnippetID(snippetID));
  try {
    URL url = new URL(dataSnippetLink(snippetID));
    print("Loading library: " + hideCredentials(url));
    try {
      loadBinaryPageToFile(openConnection(url), f);
      if (fileSize(f) == 0) fail();
    } catch {
      url = new URL("http://data.tinybrain.de/blobs/"
        + psI(snippetID));
      print("Trying other server: " + hideCredentials(url));
      loadBinaryPageToFile(openConnection(url), f);
      print("Got bytes: " + fileSize(f));
    }
    // TODO: check if we hit the "LOADING" message
    if (fileSize(f) == 0) fail();
    System.err.println("Bytes loaded: " + fileSize(f));
  } catch e {
    printStackTrace(e);
    fail("Binary snippet " + snippetID + " not found or not public");
  }
  return f;
}

Author comment

Began life as a copy of #1000675

download  show line numbers  debug dex   

Travelled to 2 computer(s): cfunsshuasjs, tvejysmllsmz

No comments. add comment

Snippet ID: #1008031
Snippet name: loadDataSnippetToFile
Eternal ID of this version: #1008031/20
Text MD5: e21348d79ee27cc772527ca8bebaa95c
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-16 23:37:17
Source code size: 903 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 82 / 82
Version history: 19 change(s)
Referenced in: [show]