|
@@ -523,22 +523,33 @@ public class CollectApi {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @RequestMapping(value = "oss/execScript/{workId}", method = RequestMethod.GET)
|
|
|
|
- public boolean execScript(@PathVariable Long workId) {
|
|
|
|
|
|
+ @RequestMapping(value = "oss/upload/{workId}", method = RequestMethod.GET)
|
|
|
|
+ public boolean ossUpload(@PathVariable Long workId) {
|
|
try {
|
|
try {
|
|
-// String result = CommandUtil.run("/Users/king/ossutilmac64 cp -r /Users/king/stmms-ms/static/images/ oss://epcc-test/ms/images/ -u");
|
|
|
|
- String imageResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getImageDir()).add(" ").add(aliYunOssConfig.getImageDir()).toString());
|
|
|
|
- LOGGER.info("oss/execScript imageResult:{}", imageResult);
|
|
|
|
- String thumbResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getThumbDir()).add(" ").add(aliYunOssConfig.getThumbDir()).toString());
|
|
|
|
- LOGGER.info("oss/execScript thumbResult:{}", thumbResult);
|
|
|
|
- String sheetResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getSheetDir()).add(" ").add(aliYunOssConfig.getSheetDir()).toString());
|
|
|
|
- LOGGER.info("oss/execScript sheetResult:{}", sheetResult);
|
|
|
|
- String watermarkResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getWatermark()).add(" ").add(aliYunOssConfig.getWatermark()).toString());
|
|
|
|
- LOGGER.info("oss/execScript watermarkResult:{}", watermarkResult);
|
|
|
|
- deleteFile(new File(systemConfig.getImageDir() + File.separator + workId));
|
|
|
|
- deleteFile(new File(systemConfig.getThumbDir() + File.separator + workId));
|
|
|
|
- deleteFile(new File(systemConfig.getSheetDir() + File.separator + workId));
|
|
|
|
- deleteFile(new File(systemConfig.getWatermark() + File.separator + workId));
|
|
|
|
|
|
+ File imageFile = new File(systemConfig.getImageDir() + File.separator + workId);
|
|
|
|
+ if (Objects.nonNull(imageFile) && imageFile.exists()) {
|
|
|
|
+ String imageResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getImageDir()).add(" ").add(aliYunOssConfig.getImageDir()).toString());
|
|
|
|
+ LOGGER.info("ossUpload imageResult:{}", imageResult);
|
|
|
|
+ deleteFile(imageFile);
|
|
|
|
+ }
|
|
|
|
+ File thumbFile = new File(systemConfig.getThumbDir() + File.separator + workId);
|
|
|
|
+ if (Objects.nonNull(thumbFile) && thumbFile.exists()) {
|
|
|
|
+ String thumbResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getThumbDir()).add(" ").add(aliYunOssConfig.getThumbDir()).toString());
|
|
|
|
+ LOGGER.info("ossUpload thumbResult:{}", thumbResult);
|
|
|
|
+ deleteFile(thumbFile);
|
|
|
|
+ }
|
|
|
|
+ File sheetFile = new File(systemConfig.getSheetDir() + File.separator + workId);
|
|
|
|
+ if (Objects.nonNull(sheetFile) && sheetFile.exists()) {
|
|
|
|
+ String sheetResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getSheetDir()).add(" ").add(aliYunOssConfig.getSheetDir()).toString());
|
|
|
|
+ LOGGER.info("ossUpload sheetResult:{}", sheetResult);
|
|
|
|
+ deleteFile(sheetFile);
|
|
|
|
+ }
|
|
|
|
+ File watermarkFile = new File(systemConfig.getWatermark() + File.separator + workId);
|
|
|
|
+ if (Objects.nonNull(watermarkFile) && watermarkFile.exists()) {
|
|
|
|
+ String watermarkResult = CommandUtil.run(new StringJoiner("").add(aliYunOssConfig.getUtil()).add(" ").add(systemConfig.getWatermark()).add(" ").add(aliYunOssConfig.getWatermark()).toString());
|
|
|
|
+ LOGGER.info("ossUpload watermarkResult:{}", watermarkResult);
|
|
|
|
+ deleteFile(watermarkFile);
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
return false;
|
|
return false;
|
|
@@ -552,11 +563,6 @@ public class CollectApi {
|
|
* @param file
|
|
* @param file
|
|
*/
|
|
*/
|
|
public void deleteFile(File file) throws Exception {
|
|
public void deleteFile(File file) throws Exception {
|
|
- //判断文件不为null或文件目录存在
|
|
|
|
- if (Objects.isNull(file) || !file.exists()) {
|
|
|
|
- LOGGER.info(file.getAbsolutePath() + " 文件删除失败,请检查文件路径是否正确");
|
|
|
|
- throw new Exception("无需重复上传");
|
|
|
|
- }
|
|
|
|
//取得这个目录下的所有子文件对象
|
|
//取得这个目录下的所有子文件对象
|
|
File[] files = file.listFiles();
|
|
File[] files = file.listFiles();
|
|
//遍历该目录下的文件对象
|
|
//遍历该目录下的文件对象
|