使用了hutool工具类,Result是返回值的统一封装
@RequiresAuthentication
@GetMapping("/createdImage")
public Result createdImage() throws FileNotFoundException {
File[] files = FileUtil.ls(
"D:\\myporject\\springboot-vant\\src\\main\\resources\\static\\LoginImage");
List list = new ArrayList();
for (File file : files) {
byte[] fileByte = IoUtil.readBytes(new FileInputStream(file));
String encode = "data:image/png;base64," + Base64Encoder.encode(fileByte);
list.add(encode);
}
return Result.succ(list);
}