| | |
| | | |
| | | private final static Log log = LogFactory.getLog(UploadAttachService.class); |
| | | |
| | | private static final String NO_FILE = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NOT_FOUND, "文件找不到")); |
| | | |
| | | /** |
| | | * 获取表名 |
| | | */ |
| | |
| | | * 下载文件 |
| | | */ |
| | | public void download(String guid, HttpServletResponse res) { |
| | | download(guid, false, res); |
| | | } |
| | | |
| | | /** |
| | | * 下载文件 |
| | | */ |
| | | public void download(String guid, boolean inline, HttpServletResponse res) { |
| | | try { |
| | | if (StringHelper.isEmpty(guid)) { |
| | | WebHelper.write2Page(res, NO_FILE); |
| | | WebHelper.writeStr2Page(res, StaticData.NO_FILE); |
| | | return; |
| | | } |
| | | |
| | | AttachEntity entity = attachService.selectByGuid(guid); |
| | | if (entity == null) { |
| | | WebHelper.write2Page(res, NO_FILE); |
| | | WebHelper.writeStr2Page(res, StaticData.NO_FILE); |
| | | return; |
| | | } |
| | | |
| | | String file = pathHelper.getConfig().getUploadPath() + File.separator + entity.getPath(); |
| | | WebHelper.download(file, entity.getName(), res); |
| | | } catch (Exception ex) { |
| | | try { |
| | | String msg = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.ERROR, "文件下载出错")); |
| | | WebHelper.write2Page(res, msg); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | String filePath = pathHelper.getConfig().getUploadPath() + File.separator + entity.getPath(); |
| | | File file = new File(filePath); |
| | | if (!file.exists() || file.isDirectory()) { |
| | | WebHelper.writeJson2Page(res, "文件不存在"); |
| | | } |
| | | |
| | | WebHelper.download(filePath, entity.getName(), inline, res); |
| | | } catch (Exception ex) { |
| | | WebHelper.writeJson2Page(res, "文件下载出错"); |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | |
| | | for (MetaFileEntity mf : list) { |
| | | if (mf.getName().contains(StaticData.ZIP)) { |
| | | List<String> subs = getZipFiles(mf, path); |
| | | if (null == subs || subs.size() > 0) { |
| | | if (null != subs && subs.size() > 0) { |
| | | files.addAll(subs); |
| | | } |
| | | continue; |