| | |
| | | } |
| | | |
| | | MetaEntity me = new MetaEntity(); |
| | | List<MetaFileEntity> list = uploaderService.uploadData(me, ue, req, res); |
| | | List<MetaFileEntity> list = uploaderService.uploadData(me, null, req, res); |
| | | if (list.size() == 0 || me.getDirid() == 0) { |
| | | return fail("没有找到上传数据", null); |
| | | } |
| | |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, ue, req, res); |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, path, req, res); |
| | | if (list.size() == 0) { |
| | | return fail("没有找到上传数据", null); |
| | | } |
| | |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, ue, req, res); |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, null, req, res); |
| | | if (list == null || list.size() < StaticData.FOUR) { |
| | | return fail("没有找到已上传的数据或不完整", null); |
| | | } |
| | |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<MetaFileEntity> meList = uploaderService.uploadData(null, ue, req, res); |
| | | List<MetaFileEntity> meList = uploaderService.uploadData(null, null, req, res); |
| | | if (meList == null || meList.size() < StaticData.FOUR) { |
| | | return fail("没有找到已上传的数据或不完整", null); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取临时路径 |
| | | */ |
| | | public String getTempPath(String subPath) { |
| | | if (!StringHelper.isEmpty(subPath)) { |
| | | String path = config.getTempPath() + File.separator + subPath; |
| | | |
| | | File file = new File(path); |
| | | if (file.exists() && file.isDirectory()) { |
| | | return path; |
| | | } |
| | | } |
| | | |
| | | return getTempPath(); |
| | | } |
| | | |
| | | /** |
| | | * 删除旧路径 |
| | | */ |
| | | public void deleteOldPath(String tempPath) { |
| | |
| | | /** |
| | | * 上传文件 |
| | | */ |
| | | public <T> List<MetaFileEntity> uploadData(T t, UserEntity ue, HttpServletRequest request, HttpServletResponse res) throws Exception { |
| | | StandardMultipartHttpServletRequest req = (StandardMultipartHttpServletRequest) request; |
| | | public <T> List<MetaFileEntity> uploadData(T t, String path, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | StandardMultipartHttpServletRequest request = (StandardMultipartHttpServletRequest) req; |
| | | req.setCharacterEncoding("utf-8"); |
| | | res.setContentType("application/json;charset=utf-8"); |
| | | |
| | | if (t != null) { |
| | | setEntity(t, req); |
| | | setEntity(t, request); |
| | | } |
| | | List<MetaFileEntity> list = getFiles(req); |
| | | List<MetaFileEntity> list = getFiles(path,request); |
| | | |
| | | return list; |
| | | } |
| | |
| | | /** |
| | | * 获取文件 |
| | | */ |
| | | private List<MetaFileEntity> getFiles(StandardMultipartHttpServletRequest req) throws Exception { |
| | | private List<MetaFileEntity> getFiles(String subPath,StandardMultipartHttpServletRequest req) throws Exception { |
| | | List<MetaFileEntity> list = new ArrayList<MetaFileEntity>(); |
| | | |
| | | String path = pathHelper.getTempPath(); |
| | | String path = pathHelper.getTempPath(subPath); |
| | | Iterator<String> iterator = req.getFileNames(); |
| | | while (iterator.hasNext()) { |
| | | MultipartFile file = req.getFile(iterator.next()); |