时间:2021-07-01 10:21:17 帮助过:21人阅读
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;
}
上传的图片转换 base64字符串 存入数据库
标签:return throws bsp encoder 转换 ble tin file 字符串