+ Node fileNode;
+ if (part.getName().endsWith(".jpg")) {
+ // Fix metadata
+ Path temp = Files.createTempFile("image", ".jpg");
+ try {
+ ImageProcessor imageProcessor = new ImageProcessor(() -> part.getInputStream(),
+ () -> Files.newOutputStream(temp));
+ imageProcessor.process();
+ fileNode = JcrUtils.copyStreamAsFile(submission, part.getName(),
+ Files.newInputStream(temp));
+ } finally {
+ Files.deleteIfExists(temp);
+ }
+ } else {
+ fileNode = JcrUtils.copyStreamAsFile(submission, part.getName(), part.getInputStream());
+ }