Exemplo n.º 1
0
  public void store(File file, String path) throws Exception {

    int n = 0;
    URL url = new URL(base + path);
    SHA1 sha1 = SHA1.digest(file);
    MD5 md5 = MD5.digest(file);

    TaggedData go = client.build().put().upload(file).updateTag().asTag().go(url);

    switch (go.getState()) {
      case NOT_FOUND:
      case OTHER:
        throw new IOException("Could not store " + path + " from " + file + " with " + go);

      case UNMODIFIED:
      case UPDATED:
      default:
        break;
    }
    client.build().put().upload(sha1.asHex()).asTag().go(new URL(base + path + ".sha1"));
    client.build().put().upload(md5.asHex()).asTag().go(new URL(base + path + ".md5"));
  }