/** * Returns length of Thumbnail on disk * * @param thumbnail */ public long getThumbnailLength(Thumbnail thumbnail) { File f = new File(getThumbnailPath(thumbnail.getId())); return f.length(); }
/** * Returns whether or not a thumbnail exists on disk. * * @param thumbnail The thumbnail metadata. * @return See above. */ public boolean getThumbnailExists(Thumbnail thumbnail) throws IOException { String path = getThumbnailPath(thumbnail.getId()); return new File(path).exists(); }
/** * Creates thumbnail on disk using byte array * * @param thumbnail * @param buf * @throws IOException */ public void createThumbnail(Thumbnail thumbnail, byte[] buf) throws IOException { String path = getThumbnailPath(thumbnail.getId()); createSubpath(path); FileOutputStream stream = new FileOutputStream(path); stream.write(buf); stream.close(); }
/** * Return FileOutputStream of Thumbnail * * @param thumbnail * @return a {@link FileOutputStream} * @throws IOException */ public FileOutputStream getThumbnailOutputStream(Thumbnail thumbnail) throws IOException { String path = getThumbnailPath(thumbnail.getId()); createSubpath(path); return new FileOutputStream(path); }
String thumbnailPath = getThumbnailPath(id); file = new File(thumbnailPath); if (file.exists())
/** * Return byte array of Thumbnail, providing byte array * * @param thumbnail * @param buf * @return a byte array * @throws IOException */ public byte[] getThumbnail(Thumbnail thumbnail, byte[] buf) throws IOException { String path = getThumbnailPath(thumbnail.getId()); FileInputStream stream = new FileInputStream(path); try { stream.read(buf, 0, buf.length); } finally { Utils.closeQuietly(stream); } return buf; }
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String thumbnailPath = thumbnailService.getThumbnailPath(thumbnailId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(thumbnailPath));
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String thumbnailPath = thumbnailService.getThumbnailPath(thumbnailId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(thumbnailPath));