|
@@ -1,13 +1,16 @@
|
|
package com.management.platform.controller;
|
|
package com.management.platform.controller;
|
|
|
|
|
|
|
|
+import com.management.platform.task.SFTPAsyncUploader;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import org.apache.log4j.LogManager;
|
|
import org.apache.log4j.LogManager;
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
@@ -21,6 +24,8 @@ public class CommonUploadController {
|
|
Logger logger = LogManager.getLogger(org.apache.logging.log4j.LogManager.ROOT_LOGGER_NAME);
|
|
Logger logger = LogManager.getLogger(org.apache.logging.log4j.LogManager.ROOT_LOGGER_NAME);
|
|
@Value(value = "${upload.path}")
|
|
@Value(value = "${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
|
|
+ @Autowired
|
|
|
|
+ public SFTPAsyncUploader sftpAsyncUploader;
|
|
|
|
|
|
@RequestMapping(value="uploadFile")
|
|
@RequestMapping(value="uploadFile")
|
|
public HttpRespMsg uploadFile(MultipartFile multipartFile) {
|
|
public HttpRespMsg uploadFile(MultipartFile multipartFile) {
|
|
@@ -50,6 +55,10 @@ public class CommonUploadController {
|
|
inputStream.close();
|
|
inputStream.close();
|
|
outputStream.close();
|
|
outputStream.close();
|
|
msg.data = serverName;
|
|
msg.data = serverName;
|
|
|
|
+
|
|
|
|
+ // 上传到SFTP服务器
|
|
|
|
+ sftpAsyncUploader.uploadFileAsync(file);
|
|
|
|
+
|
|
} catch (Exception exception) {
|
|
} catch (Exception exception) {
|
|
exception.printStackTrace();
|
|
exception.printStackTrace();
|
|
logger.error(exception.getMessage());
|
|
logger.error(exception.getMessage());
|