public String fileToStr(MultipartFile file) throws IOException{
bate[] data = null;
InputStream is = file.getInputStream();
data = new byte[is.available()];
is.read(data);
is.close();
String encode = Base64.getEncoder().encodeToString(data);
String pre ="data:image/png;base64,"; // 加上前缀,用于html img标签显示成图片
return pre +encode;
}
原文地址:https://www.cnblogs.com/dayuss/p/11572102.html
时间: 2024-10-12 19:51:20