|
@@ -23,7 +23,6 @@ import cn.com.qmth.examcloud.web.filestorage.FileStorageType;
|
|
|
import cn.com.qmth.examcloud.web.filestorage.YunHttpRequest;
|
|
|
import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
|
|
|
import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
|
-import cn.com.qmth.examcloud.web.upyun.UpYunClient;
|
|
|
import cn.com.qmth.examcloud.web.upyun.UpyunSiteManager;
|
|
|
|
|
|
/**
|
|
@@ -146,9 +145,6 @@ public class FileStorageUtil {
|
|
|
* @return 可直接访问的文件地址
|
|
|
*/
|
|
|
public static String realPath(String path) {
|
|
|
- if (StringUtils.isBlank(path)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
if (StringUtils.isBlank(path)) {
|
|
|
throw new StatusException("3001", "文件路径是空");
|
|
@@ -157,7 +153,7 @@ public class FileStorageUtil {
|
|
|
path = diposeOldPath(path);
|
|
|
// 如果是全路径直接返回
|
|
|
if (path.startsWith("http") || path.startsWith("https")) {
|
|
|
- return replaceUpyunDomain(path);
|
|
|
+ return path;
|
|
|
}
|
|
|
// 根据路径头获取对应的处理类
|
|
|
FileStorage fs = SpringContextHolder.getBean(FileStorageHelper.getHead(path).toLowerCase() + beanSuff,
|
|
@@ -366,9 +362,6 @@ public class FileStorageUtil {
|
|
|
* @return 可直接访问的文件地址,如果没有配置备用地址,则返回主域名地址
|
|
|
*/
|
|
|
public static String realPathBackup(String path) {
|
|
|
- if (StringUtils.isBlank(path)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
if (StringUtils.isBlank(path)) {
|
|
|
throw new StatusException("6001", "文件路径是空");
|
|
|
}
|
|
@@ -376,7 +369,7 @@ public class FileStorageUtil {
|
|
|
path = diposeOldPath(path);
|
|
|
// 如果是全路径直接返回
|
|
|
if (path.startsWith("http") || path.startsWith("https")) {
|
|
|
- return replaceUpyunDomain(path);
|
|
|
+ return path;
|
|
|
}
|
|
|
// 根据路径头获取对应的处理类
|
|
|
FileStorage fs = SpringContextHolder.getBean(FileStorageHelper.getHead(path).toLowerCase() + beanSuff,
|
|
@@ -409,20 +402,4 @@ public class FileStorageUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static String replaceUpyunDomain(String path) {
|
|
|
- String oldUpyunDomain = "static.qmth.com.cn";
|
|
|
- String oldUpyunBackupDomain = "static-backup.qmth.com.cn";
|
|
|
- String replaceStr = null;
|
|
|
- UpYunClient c = UpyunSiteManager.getUpYunClientByUpyunId("1");
|
|
|
- if (path.contains(oldUpyunDomain)) {
|
|
|
- replaceStr = c.getDomain();
|
|
|
- }
|
|
|
- if (path.contains(oldUpyunBackupDomain)) {
|
|
|
- replaceStr = c.getDomainBackup();
|
|
|
- }
|
|
|
- path = path.replace("https://", "");
|
|
|
- path = path.replace("http://", "");
|
|
|
- path=path.substring(path.indexOf("/")+1);
|
|
|
- return FileStorageHelper.getUrl(replaceStr, path);
|
|
|
- }
|
|
|
}
|