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

25
LINES

< > BotCompany Repo | #1005826 // uploadToImageServerIfNotThere - returns URL

JavaX fragment (include)

// there are random upload errors...
static int uploadToImageServerIfNotThere_tries = 3;

static S uploadToImageServerIfNotThere(BufferedImage img, S name) {
  ret uploadToImageServerIfNotThere(null, img, name);
}

static S uploadToImageServerIfNotThere(File f, BufferedImage img, S name) {
  S md5 = md5OfRGBImage(new RGBImage(img));
  Throwable lastException = null;
  for tries to uploadToImageServerIfNotThere_tries: try {
    long id = imageServerCheckMD5(md5);
    if (id == 0)
      ret uploadToImageServer_new(f, img, name);
    else
      ret snippetImgLink(fsI(id));
  } catch e {
    lastException = printException(e);
  }
  fail(lastException);
}

sS uploadToImageServerIfNotThere(File f) {
  ret uploadToImageServerIfNotThere(f, loadImage2(f), fileName(f));
}

Author comment

Began life as a copy of #1004609

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1005826
Snippet name: uploadToImageServerIfNotThere - returns URL
Eternal ID of this version: #1005826/7
Text MD5: 10aebd4a204cc649b03277b8620b479d
Author: stefan
Category: javax / images
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-02 09:58:41
Source code size: 798 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 543 / 590
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1009029 - uploadJPEGToImageServer - returns URL