|
|
@@ -14,6 +14,7 @@ import javax.imageio.stream.ImageInputStream;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.boot.web.server.WebServerException;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
@@ -400,12 +401,29 @@ public class FileUploadUtil {
|
|
|
// return null;
|
|
|
// }
|
|
|
// }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Return the absolute temp dir for given web server.
|
|
|
+ * @param prefix server name
|
|
|
+ * @return the temp dir for given server.
|
|
|
+ */
|
|
|
+ public static String createTempDir(String temp) {
|
|
|
+ try {
|
|
|
+ File tempDir = File.createTempFile("eladmin",temp);
|
|
|
+ tempDir.delete();
|
|
|
+ tempDir.mkdir();
|
|
|
+ tempDir.deleteOnExit();
|
|
|
+ return tempDir.getAbsolutePath()+"/";
|
|
|
+ }
|
|
|
+ catch (IOException ex) {
|
|
|
+ throw new WebServerException(
|
|
|
+ "Unable to create tempDir. java.io.tmpdir is set to " + System.getProperty("java.io.tmpdir"), ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
public static String savePdf(String html, String businessNo, String orderId) {
|
|
|
if (html == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- String uploadPath = AppConfigInfo.APP_UPLOAD_PATH;
|
|
|
+ String uploadPath = createTempDir("upload");
|
|
|
// 拼接文件路径
|
|
|
String fileName = UUIDGenerator.uuid() + ".pdf";
|
|
|
String path = businessNo + "/" + StepStatusEnum.getType(orderId) + "/" + fileName;
|