Skip to content
Snippets Groups Projects
Commit 23639865 authored by Alžbeta Hajná's avatar Alžbeta Hajná
Browse files

feat(visualization): saved PDF with current time to be able to create multiple pdfs

parent efcc20d0
No related branches found
No related tags found
3 merge requests!54Merge develop into main,!48Scenario,!44Security
This commit is part of merge request !44. Comments created here will be created in the context of that merge request.
......@@ -14,6 +14,8 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Service
public class VisualizationService {
......@@ -110,12 +112,17 @@ public class VisualizationService {
Files.createDirectories(outputDirPath);
}
String outputFileName = String.format("car-%s.pdf", carDto.getId());
// Save generated file
Files.write(outputDirPath.resolve(outputFileName), baos.toByteArray());
Files.write(outputDirPath.resolve(getFilename()), baos.toByteArray());
return new ByteArrayResource(baos.toByteArray());
}
}
private String getFilename() {
LocalDateTime currentTime = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss");
return String.format("car-updated-%s.pdf", currentTime.format(formatter));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment