|
|
@@ -217,53 +217,4 @@ public class SystemFileController extends BaseRESTfulController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @PostMapping("/insertFiles")
|
|
|
- public RESTfulResult insertFiles(String fileUuids,MultipartRequest request) {
|
|
|
- String filenames = "";
|
|
|
- //添加到files数组
|
|
|
- List<MultipartFile> files = new ArrayList<>();
|
|
|
- Iterator<String> fileNames = request.getFileNames();
|
|
|
- //记录上传成功的图片;
|
|
|
- int successFiles = 0;
|
|
|
- int size = Iterators.size(fileNames);
|
|
|
- System.out.println(size);
|
|
|
- for(int j = 0 ; j<size;j++) {
|
|
|
- try {
|
|
|
- MultipartFile file = request.getFile("file"+j);
|
|
|
- //获取系统时间
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd");
|
|
|
- //获取文件名
|
|
|
- String oldName = file.getOriginalFilename();
|
|
|
- //取当前时间的长整形值包含毫秒
|
|
|
- String newName = IDutils.getImageName();
|
|
|
- //重新命名文件
|
|
|
- newName = newName + oldName.substring(oldName.lastIndexOf("."));
|
|
|
- String filePath = simpleDateFormat.format(new Date());
|
|
|
- //获取输入流
|
|
|
- InputStream inputStream = file.getInputStream();
|
|
|
- boolean result = ftpFileUtil.uploadToFtp(inputStream, filePath, newName, false);
|
|
|
- inputStream.close();
|
|
|
- if (result) {
|
|
|
- SystemFile uploadFile = new SystemFile();
|
|
|
- uploadFile.setFilename(oldName);
|
|
|
- uploadFile.setFilepath(filePath + "/" + newName);
|
|
|
- uploadFile.setId("alternateFields1");
|
|
|
- SystemFile modela = systemFileService.add(uploadFile);
|
|
|
- //if (modela != null) {
|
|
|
- // filesid += "," + modela.getId();
|
|
|
- //}
|
|
|
- successFiles++;
|
|
|
- } else {
|
|
|
- //return failed(null, "上传文件失败");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- return success();
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
}
|