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

linux centos7 环境下 no such file or directory

主图==========

目录

  • 1.问题描述
  • 2.主要原因
    • 2.1修改后代码
    • 2.2修改前代码
  • 总结
  • 参考


1.问题描述

预览excel文件时无法找到对应的html文件

在这里插入图片描述

2.主要原因

在这里插入图片描述
异常原因:代码获取的是系统的tmp文件,但是linux环境环境中心tmp目录是没有权限的,所以不能获取系统的根目录下的tmp,需要自己创建个临时目录

2.1修改后代码

在项目路径下创建临时文件

String userTemRoot = "/excel/media/";String userTemPath = fileHost + userTemRoot;File temFolder = new File(userTemPath);if (null == temFolder || !temFolder.exists()) {temFolder.mkdirs();}String excelPath = userTemPath  + UUIDGenerate.getUnid() + "." + ext;File file = new File(excelPath);InputStream in = InputStreamUtil.byteToInputStream(buffer);InputStreamUtil.inputStreamToFile(in, file);content = ExcelToHtml.excelWriteToHtml(excelPath);jsonObject.put("data", content);return jsonObject;

2.2修改前代码

        String temRoot = System.getProperty(JAVA_IO_TMPDIR);String temPath = temRoot + "XLS";File temFolder = new File(temPath);if (null == temFolder || !temFolder.exists()) {temFolder.mkdirs();}String excelPath = temPath + File.separator + UUIDGenerate.getUnid() + "." + ext;File file = new File(excelPath);InputStream in = InputStreamUtil.byteToInputStream(buffer);InputStreamUtil.inputStreamToFile(in, file);content = ExcelToHtml.excelWriteToHtml(excelPath);jsonObject.put(DATA, content);return jsonObject;

总结

一些文件的读写在window下的执行时没有阻碍的,但是到了linux环境下需要考虑一些权限问题,面向的大部分用户都是没有完整权限的普通用户,没有权限读取根目录下的临时文件。

参考

Linux中提示No such file or directory解决方法

给个三连吧 谢谢谢谢谢谢了
在这里插入图片描述

http://www.lryc.cn/news/194563.html

相关文章:

  • Nginx 反向代理 SSL 证书绑定域名
  • SpringBoot 集成 JMS 与 IBMMQ 代码示例教程
  • 大模型之Prompt研究和技巧
  • 掌握Golang匿名函数
  • HarmonyOS云开发基础认证---练习题二
  • ffmpeg视频解码器的配置选项含义
  • enter ubuntu boot option in virt-manager
  • 电商运营该如何做 AB 测试
  • go环境部署
  • HTTP/2 中的漏洞
  • 智能油烟机 优化烹饪体验
  • 啥?PS一秒成图?Adobe的逆天黑科技大公开
  • 扫描器(xray和bp联动)
  • [C++]:1.初识C++和C语言缺陷补充。
  • BUUCTF学习(三): PHP 代码审计
  • 推荐《Blue prison》
  • goland安装教程
  • java中okhttp和httpclient那个效率高
  • 内存占用问题
  • 代码随想录二刷 Day 34
  • 软件开源快速开发框架:降本增效,助力流程化办公!
  • Flink on k8s容器日志生成原理及与Yarn部署时的日志生成模式对比
  • AD20绘制电路板的外形
  • linux 设置开机启动
  • IDEA实现远程Debug调试
  • SpringBoot项目入门: IDEA 创建SpringBoot项目
  • Vue2+SpringBoot实现数据导出到csv文件并下载
  • NewStarCTF2023week2-base!(base低位隐写)
  • 众和策略:国际油价走高,石油板块强势拉升,通源石油、和顺石油等涨停
  • C++笔记之获取线程ID以及线程ID的用处