Class XUploadContentTransformer


  • public final class XUploadContentTransformer
    extends Object
    Helper for transforming the content of an XUpload. For example, the form designer offers users an option where they can specify that images should be compressed on the server before being stored.
    Since:
    8.2.0
    • Method Detail

      • transformXUpload

        public static IXUpload transformXUpload​(IXUpload upload,
                                                List<IUploadPostProcessor> postProcessors)
                                         throws IOException
        Transforms the content of the given upload. For example, the form designer offers users an option where they can specify that images should be compressed on the server before being stored.
        Parameters:
        upload - The content to transform.
        postProcessors - the chain of postprocessors to be applied (in the given order)
        Returns:
        The transformed content, which is
        • identical to the passed one if no postprocessing has been applied
        • null if the passed upload itself or one of the postprocessing results is null
        • a new IXUpload instance with the new content if the postprocessing chain was executed successfully
        Throws:
        IOException
      • createImagePostProcessor

        @Deprecated(since="8.6.0")
        public static IUploadPostProcessor createImagePostProcessor​(Integer targetWidth,
                                                                    Integer targetHeight,
                                                                    String targetImgFormat,
                                                                    Double targetQuality,
                                                                    Path tmpDir,
                                                                    Consumer<String> protocolHandler)
        Deprecated.
        Use ImageUploadProcessor instead, which also removes the metadata of the image and which can be used without compressing the image at all. Note that the postprocessor returned here now removes the metadata as well, as it is the very same postprocessor.
        Creates a postprocessor that compresses uploaded images.
        Parameters:
        targetWidth - Width the image should be scaled down to, or null when the width does not matter.
        targetHeight - Height the image should be scaled down to, or null when the height does not matter.
        targetImgFormat - Format the image should be converted to, or auto to keep its format.
        targetQuality - Quality (between 0 and 100) the image should be stored with.
        tmpDir - Directory to store the processed image in until it has been read.
        protocolHandler - Accepts the i18n keys of the messages to add to the form record's history.
        Returns:
        The postprocessor for uploaded images.