拆分-图片-取消base64编码解决中文乱码问题

This commit is contained in:
liyawei
2022-06-10 16:43:03 +08:00
parent bc072cc262
commit c93ab796b3
4 changed files with 101 additions and 107 deletions
@@ -2570,9 +2570,9 @@ public class FileSpiltService {
try {
// String fileUrl = splitUrl + "/" + filepathandname;
BASE64Encoder base64Encoder = new BASE64Encoder();
String encode = base64Encoder.encode(filepathandname.getBytes(StandardCharsets.UTF_8));
String path = splitUrl+"/jero-boot/sys/split/file/getImage?fileUrl="+encode;
// BASE64Encoder base64Encoder = new BASE64Encoder();
// String encode = base64Encoder.encode(filepathandname.getBytes(StandardCharsets.UTF_8));
String path = splitUrl+"/jero-boot/sys/split/file/getImage?fileUrl="+filepathandname;
CosBootUtil.uploadByte(bytev, filepathandname);
String imgCon = path;
String imgConVal = "<img class=\"wordImg\" src=\"" + path + "\">";
@@ -1222,9 +1222,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
oSSFile = ossFileService.getById(oSSFile.getId());
isText = false;
BASE64Encoder base64Encoder = new BASE64Encoder();
String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + encode;
// BASE64Encoder base64Encoder = new BASE64Encoder();
// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + oSSFile.getUrl();
// String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1);
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
@@ -1272,9 +1272,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
oSSFile = ossFileService.getById(oSSFile.getId());
isText = false;
BASE64Encoder base64Encoder = new BASE64Encoder();
String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + encode;
// BASE64Encoder base64Encoder = new BASE64Encoder();
// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + oSSFile.getUrl();
// String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1);
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
@@ -1319,9 +1319,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
if (oSSFile != null) {
isText = false;
BASE64Encoder base64Encoder = new BASE64Encoder();
String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + encode;
// BASE64Encoder base64Encoder = new BASE64Encoder();
// String encode = base64Encoder.encode(oSSFile.getUrl().getBytes(StandardCharsets.UTF_8));
String path = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + oSSFile.getUrl();
// String path = imgpath + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf(File.separator)+1);
String imgCon = "<img class=\"wordImg\" src=\"" + path + "\">";
valEO.setType("IMG");
@@ -3167,19 +3167,18 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
valContent.add(lastOne);
FileSplitValImgExportDto fileSplitValImgExportDto = new FileSplitValImgExportDto();
fileSplitValImgExportDto.setImgName(imgUUIndex+".png");
String url = imgContent.substring(imgContent.lastIndexOf("=")+1);
byte[] bytes = new byte[0];
try {
bytes = base64Decoder.decodeBuffer(url);
url = new String(bytes, "utf-8");
fileSplitValImgExportDto.setImgPath(url);
}catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
String url = imgContent.substring(imgContent.lastIndexOf("=") + 1);
// byte[] bytes = new byte[0];
// try {
// bytes = base64Decoder.decodeBuffer(url);
// url = new String(bytes, "utf-8");
// }catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
fileSplitValImgExportDto.setImgPath(url);
// fileSplitValImgExportDto.setImgPath(imgContent.substring(imgContent.lastIndexOf(File.separator)+1));
allImgList.add(fileSplitValImgExportDto);