File file = new File(mFile.getOriginalFilename());
FileUtils.copyInputStreamToFile(mFile.getInputStream(), file);
try (FileInputStream fis = new FileInputStream(file)) {
byte[] buf = new byte[(int) file.length()];
fis.read(buf);
return new String(Base64.encodeBase64(buf), StandardCharsets.ISO_8859_1);
} catch (IOException e) {
log.error(e.getMessage(), e);
} finally {
if (file.exists()) {
file.delete();
}
}
MultipartFile获取Base64编码
最新推荐文章于 2024-01-29 16:14:23 发布