当前位置: 首页 > article >正文

Minio上传html文件

内容浏览乱码问题,下载下来是正常编码。解决方法:

1、引入 文件内编码识别

<dependency>
    <groupId>com.github.jiangxincode</groupId>
    <artifactId>cpdetector</artifactId>
    <version>1.0.10</version>
</dependency>

2、加入代码

if("text/html".equals(contentType)){
    try {
        File tempFile = File.createTempFile("temp","."+suffix);
         FileOutputStream outputStream = new FileOutputStream(tempFile);
         outputStream.write(file.getBytes());
         outputStream.close();
      //  IoUtil.copy(inputStream, tempFile);
        // 判断文件编码
        String charsetName = ReadUtil.getCharsetName(tempFile);
        contentType=contentType+";charset="+charsetName;
        System.out.println("charsetName = " + charsetName);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

http://www.kler.cn/news/9522.html

相关文章:

  • 分享10个前端开发者需要掌握的DOM技巧
  • 超越辅助:分享一个基于GPT引擎的免费AI工具
  • 一文解读基于PaddleSeg的钢筋长度超限监控方案
  • 管廊隧道怎么定位人员?分享管廊隧道人员定位系统解决方案
  • ubuntu16.04搭建gitlab
  • 原油期货是什么?原油期货交易盈利技巧有哪些?
  • MyBatis动态SQL教程:灵活处理复杂SQL场景,提升性能与可维护性
  • 二叉树练习题(递归展开图详解哦)
  • 21. 合并两个有序链表(Java)
  • 坦克大战第一阶段代码
  • 电子学会2023年3月青少年软件编程python等级考试试卷(一级)真题,含答案解析
  • 6、springboot快速使用
  • USB在虚拟机中不显示以及没有访问权限
  • C程序设计-小学生计算机教学辅助系统(四则运算)
  • 磁盘移臂调度算法
  • 【Bug解决】AttributeError: ‘DataParallel‘ object has no attribute ‘XXX‘
  • 【store商城项目08】删除用户的收获地址
  • 建龙转债上市价格预测 - 配了38张道氏,希望不要乱跌
  • unity--半圆包围posiotion
  • springboot+jwt令牌简单登录案例