Some minor changes.
Optional.ofNullable(null); will always return Optional.empty(), so it's better to be explicit.
Optional.ofNullable(x) is not meaningful if x cannot be null. It's better to use Optional.of(x)
imagefile cannot be null, because if imageFile is null, the method selectAndSaveImage exits already on line 185.
Some minor changes. Optional.ofNullable(null); will always return Optional.empty(), so it's better to be explicit.
Optional.ofNullable(x) is not meaningful if x cannot be null. It's better to use Optional.of(x) imagefile cannot be null, because if imageFile is null, the method selectAndSaveImage exits already on line 185.