|
|
@@ -20,11 +20,13 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.poi.excel.BigExcelWriter;
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import me.zhengjie.exception.BadRequestException;
|
|
|
+import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.poi.util.IOUtils;
|
|
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
@@ -353,4 +355,20 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|
|
public static String getMd5(File file) {
|
|
|
return getMd5(getByte(file));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将文件内容转换成Base64编码
|
|
|
+ *
|
|
|
+ * @param path
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String encodeBase64File(String path) throws Exception {
|
|
|
+ File file = new File(path);
|
|
|
+ FileInputStream inputFile = new FileInputStream(file);
|
|
|
+ byte[] buffer = new byte[(int) file.length()];
|
|
|
+ inputFile.read(buffer);
|
|
|
+ inputFile.close();
|
|
|
+ return Base64.encodeBase64String(buffer);
|
|
|
+ }
|
|
|
}
|