Class NamedAttachmentProxy


public class NamedAttachmentProxy extends AttachmentProxy
A utility class to retrieve attachments.
This supports downloading the images from the normal URL, as well as downloading the image with a specific width and height.

This is a specialization of AttachmentProxy, which is aware of the file name of the attachment.

  • Constructor Details

  • Method Details

    • getFileName

      @Nonnull public String getFileName()
      The file name of the attachment.
      Returns:
      The file name
    • downloadAsFileUpload

      @Nonnull public FileUpload downloadAsFileUpload(int width, int height)
      Returns a FileUpload which supplies a data stream of this attachment, with the original attachment's file name and at the specified size.
      The returned FileUpload can be reused safely, and does not need to be closed.

      The attachment, if an image, may be resized at any size, however if the size does not fit the ratio of the image, then it will be cropped as to fit the target size.
      If the attachment is not an image then the size parameters are ignored and the file is downloaded.

      Parameters:
      width - The width of this image, must be positive
      height - The height of this image, must be positive
      Returns:
      FileUpload from this attachment.
      Throws:
      IllegalArgumentException - If any of the follow checks are true
      • The requested width is negative or 0
      • The requested height is negative or 0