Class ThumbnailService

java.lang.Object
engineering.everest.starterkit.media.thumbnails.ThumbnailService

@Component public class ThumbnailService extends Object
Service layer for thumbnails.

The maximum size of either height or width of a generated thumbnail can be configured using the application.media.thumbnail.max.dimension.pixels property.

  • Constructor Details

    • ThumbnailService

      @Autowired public ThumbnailService(@Value("${application.media.thumbnail.max.dimension.pixels:2400}") int maxDimensionPixels, engineering.everest.starterkit.filestorage.FileService fileService, ThumbnailMappingRepository thumbnailMappingRepository)
  • Method Details

    • streamThumbnailForOriginalFile

      public InputStream streamThumbnailForOriginalFile(UUID fileId, int width, int height) throws IOException
      Generates a thumbnail for a file stored by one of the deduplicating filestores.

      Generated thumbnails are cached on the ephemeral file store. Callers are responsible for closing the returned input stream.

      Parameters:
      fileId - UUID returned by the PermanentDeduplicatingFileStore or the EphemeralDefuplicatingFileStore
      width - desired thumbnail width
      height - desried thumbnail height
      Returns:
      an input stream to retrieve a thumbnail.
      Throws:
      IOException - if the original file cannot be read
      IllegalArgumentException - if the thumbnail dimensions are impossibly small or larger than the maximum supported.
    • getAllThumbnailFileIds

      public Set<UUID> getAllThumbnailFileIds()
    • deleteAllThumbnailMappings

      public void deleteAllThumbnailMappings()
      Clear all thumbnail mappings.