ssh上传数据库+指定路径
来源:互联网 发布:男友尺寸知乎 编辑:程序博客网 时间:2024/06/05 09:25
最近写了个上传下载。
// 文件路径 private File file; private String fileFileName; private String fileContentType; private String msg; @Autowired private FileUploadService fileService; private static final String upPath = CommonUtil.getProsValue("UPLOAD_PATH"); /** * 上传 */ @Action(value = "upload", results = {@Result(name = "upload", location = "/jsp/upload.jsp")})public String upload() throws Exception { String upFlag = this.getRequest().getParameter("upFlag"); try { if (null != file) { Annex annex = new Annex(); annex.setAnnexId(CommonUtil.getUuid()); annex.setAnnexName(fileFileName); annex.setCrtDate(new Date()); annex.setCrtUser("xiao"); if ("1".equals(upFlag)) { // 转为blob存到数据库 Blob blob = upToOracle(); annex.setAnnexCont(blob); } else { // 上传至服务器上 // String path = request.getSession().getServletContext().getRealPath(upPath); String path = upPath; upFilePath(path); annex.setAnnexPath(path + "/" + fileFileName); } fileService.saveAnnex(annex); } } catch (Exception e) { System.out.println("上传附件错误。"); } return "upload"; } /** * 转为blob存到数据库 * * @throws IOException */ private Blob upToOracle() throws IOException { FileInputStream fis = new FileInputStream(file); Blob blob = Hibernate.createBlob(fis); fis.close(); return blob; } /** * 上传至服务器上 */ private void upFilePath(String path) throws Exception { File fosFile = new File(path); // 上传文件夹不存在时如何自动创建文件夹 if (!fosFile.exists()) { fosFile.mkdirs(); } System.out.println(path); FileOutputStream fos = new FileOutputStream(path + "/" + fileFileName); FileInputStream fis = new FileInputStream(file); byte[] buffer = new byte[1024]; int len = 0; while ((len = fis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fis.close(); fos.close(); }
0 0
- ssh上传数据库+指定路径
- ssh下载数据库blob+指定路径下文件
- php上传图片到指定位置路径保存到数据库
- 指定数据库存储路径
- php上传图片到指定位置路径保存到数据库的具体实现
- php实现文件上传到指定文件夹,文件路径或名字存入数据库,如何实现啊
- php实现文件上传到指定文件夹,文件路径或名字存入数据库,如何实现啊
- SSH项目上传图片并把图片路径存放在数据库, 及其图片的显示
- 还原数据库到指定路径
- android指定数据库的路径
- android指定数据库的路径
- struts2 上传 找不到系统指定路径
- github命令行 指定路径 修改上传
- 使用swfupload上传、预览(未保存前预览)、保存(指定根目录中的文件夹、数据库字段【图片路径】、显示)
- asp怎么把图片上传到指定的文件夹,然后在数据库中记录图片的路径
- 在指定路径创建空数据库
- c#数据库备份到指定路径
- JDBC连接指定路径的数据库
- Stopwatch 监测一段时间内一个任务是否完成
- RecyclerView添加Header和Footer
- Centos7开放端口
- 一次干掉n个同一个服务启动的进程
- sql注入原理详解(一)
- ssh上传数据库+指定路径
- Uvaoj 11375 - Matches
- 【Git分布式版本控制系统】远程仓库管理
- MyEclipse快捷键
- 模板模式
- The connection to adb is down, and a severe error has occured之问题解决
- STL源码剖析 [特殊的空间配置器](内存基本处理工具stl_uninitialized.h)
- 搭建svn服务器
- iOS-UIMenuController 和 UIResponderStandardEditActions