Exemplo n.º 1
0
  public String store(byte[] data) throws IOException {
    MessageDigest md = getDigestor();
    md.update(data);

    String urn = "urn:sha1:" + Base32.encode(md.digest());
    File dest = storeFileForUrn(urn);
    if (!dest.exists()) {
      mkParentDirs(dest);
      write(data, dest);
    }
    return urn;
  }
Exemplo n.º 2
0
  public String store(File f) throws IOException {
    MessageDigest md = getDigestor();
    FileInputStream fis = new FileInputStream(f);
    byte[] buffer = new byte[65536];
    int r;
    while ((r = fis.read(buffer)) > 0) {
      md.update(buffer, 0, r);
    }
    fis.close();

    String urn = "urn:sha1:" + Base32.encode(md.digest());
    File dest = storeFileForUrn(urn);
    if (!dest.exists()) {
      mkParentDirs(dest);
      copy(f, dest);
    }
    return urn;
  }
Exemplo n.º 3
0
 private static String generateUrl(String shareId, String roomKey) {
   return String.format("%s%s/%s/", ROOT, Base32.encode(shareId.getBytes()), roomKey);
 }