Compare commits
2 Commits
85592627d6
...
2a1c41ae98
Author | SHA1 | Date | |
---|---|---|---|
2a1c41ae98 | |||
cc1d90965b |
@ -41,6 +41,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@ -49,6 +51,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
@ -64,6 +67,7 @@ import java.util.stream.Stream;
|
||||
@Slf4j
|
||||
@RequestMapping("/file")
|
||||
public class FileController {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FileController.class);
|
||||
|
||||
@Resource
|
||||
IFileService fileService;
|
||||
@ -117,9 +121,12 @@ public class FileController {
|
||||
} else if ("drawio".equals(extendName)) {
|
||||
templateFilePath = "template/Drawio.drawio";
|
||||
}
|
||||
String url2 = ClassUtils.getDefaultClassLoader().getResource("static/" + templateFilePath).getPath();
|
||||
System.out.println("ClassUtils.getDefaultClassLoader() = " + ClassUtils.getDefaultClassLoader().getResource("st"));
|
||||
System.out.println("ClassUtils.getDefaultClassLoader().getResource(\"static\") = " + ClassUtils.getDefaultClassLoader().getResource("static"));
|
||||
// String url2 = ClassUtils.getDefaultClassLoader().getResource("static/" + templateFilePath).getPath();
|
||||
// System.out.println("ClassUtils.getDefaultClassLoader() = " + ClassUtils.getDefaultClassLoader().getResource("st"));
|
||||
// System.out.println("ClassUtils.getDefaultClassLoader().getResource(\"static\") = " + ClassUtils.getDefaultClassLoader().getResource("static"));
|
||||
String separatorInfo = File.separator;
|
||||
String url2 = getMubanFile("static" + separatorInfo + templateFilePath.replace("/", separatorInfo));
|
||||
LOGGER.info("--->>模板文件所在的路径是:{}", url2);
|
||||
System.out.println("url2 = " + url2);
|
||||
url2 = URLDecoder.decode(url2, "UTF-8");
|
||||
FileInputStream fileInputStream = new FileInputStream(url2);
|
||||
@ -160,6 +167,18 @@ public class FileController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* user.dir默认会定位到你的工程根目录,但是web项目不行如果是web项目会定位到tomcat的bin目录
|
||||
*
|
||||
* @param fileName
|
||||
*/
|
||||
public String getMubanFile(String fileName) {
|
||||
String rootPath = System.getProperty("user.dir");
|
||||
String fenge = File.separator;
|
||||
//找寻这个路径下边的 /src/main/resources/ Windows跟Linux环境分割符号不同
|
||||
return rootPath + fenge + "src" + fenge + "main" + fenge + "resources" + fenge + fileName;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建文件夹", description = "目录(文件夹)的创建", tags = {"file"})
|
||||
@RequestMapping(value = "/createFold", method = RequestMethod.POST)
|
||||
@MyLog(operation = "创建文件夹", module = CURRENT_MODULE)
|
||||
|
Loading…
Reference in New Issue
Block a user