private void storeThumbnail(AttachmentId attachemntId, BufferedImage thumbnail) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(thumbnail, THUMBNAIL_FORMAT_NAME, out); store.storeThumbnail(attachemntId, new ByteArrayInputStream(out.toByteArray())); }