47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
package com.youlai.boot.common.config;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.io.File;
|
|
|
|
public class FilePath {
|
|
// @Value("${file.upload-dir-unix}")
|
|
private static final String unixUploadDir = "/data/uploads" ;
|
|
|
|
// @Value("${file.upload-dir-windows}")
|
|
private static final String windowsUploadDir = "uploadFile";
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(FilePath.class);
|
|
|
|
|
|
public static final String TABLET_PATH = "tablet";
|
|
public static final String AVATAR_PATH = "avatar";
|
|
public static final String APK_ICON_PATH = "apkIcon";
|
|
public static final String SCREENSHOT_PATH = "screenshot";
|
|
|
|
public static String getRootPath() {
|
|
String osName = System.getProperty("os.name");
|
|
logger.info("osName: {}", osName);
|
|
if (osName.contains("Windows")) {
|
|
String projectPath = System.getProperty("user.dir");
|
|
logger.info("projectPath: {}", projectPath);
|
|
return projectPath + File.separator + windowsUploadDir;
|
|
} else {
|
|
return unixUploadDir;
|
|
}
|
|
}
|
|
|
|
public static String getAvatarPath() {
|
|
return getRootPath() + File.separator + TABLET_PATH + File.separator + AVATAR_PATH + File.separator;
|
|
}
|
|
|
|
public static String getApkIconPath() {
|
|
return getRootPath() + File.separator + TABLET_PATH + File.separator + APK_ICON_PATH + File.separator;
|
|
}
|
|
|
|
public static String getScreenshotPath() {
|
|
return getRootPath() + File.separator + TABLET_PATH + File.separator + SCREENSHOT_PATH + File.separator;
|
|
}
|
|
}
|