|
|
|
@ -18,8 +18,6 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
@Slf4j |
|
|
|
@ -41,7 +39,8 @@ public class FileOptionServiceImpl implements FileOptionService { |
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
|
//文件存放地址
|
|
|
|
|
//文件在FTP服务器所在文件夹目录
|
|
|
|
|
String dirPath = fileServer.getFtpRootDir() + String.format(IBaseEnum.getLabelByValue(fileType,FileUrlEnum.class),fileType); |
|
|
|
|
String dirPath = fileServer.getFtpRootDir() + String.format(IBaseEnum.getLabelByValue(fileType,FileUrlEnum.class),fileType)+"/"+System.currentTimeMillis()/1000; |
|
|
|
|
log.info("dirPath:{}",dirPath); |
|
|
|
|
try(InputStream in = file.getInputStream()) { |
|
|
|
|
boolean upload = FTPUtils.upload(fileServer, originalFilename, dirPath, in); |
|
|
|
|
if (!upload){ |
|
|
|
@ -125,7 +124,7 @@ public class FileOptionServiceImpl implements FileOptionService { |
|
|
|
|
String newFileName = String.format("%s.%s",fileName,extension); |
|
|
|
|
//文件存放地址
|
|
|
|
|
//文件在FTP服务器所在文件夹目录
|
|
|
|
|
String dirPath = fileServer.getFtpRootDir() + String.format(IBaseEnum.getLabelByValue(fileType,FileUrlEnum.class),fileType); |
|
|
|
|
String dirPath = fileServer.getFtpRootDir() + String.format(IBaseEnum.getLabelByValue(fileType,FileUrlEnum.class),fileType)+System.currentTimeMillis()/1000; |
|
|
|
|
try(InputStream in = file.getInputStream()) { |
|
|
|
|
boolean upload = FTPUtils.upload(fileServer, newFileName, dirPath, in); |
|
|
|
|
if (!upload){ |
|
|
|
|