|
@@ -30,6 +30,7 @@ import cn.com.qmth.examcloud.commons.base.exception.ExamCloudRuntimeException;
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
|
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
|
|
|
|
|
|
/**
|
|
|
* upyun SDK定制版
|
|
@@ -75,6 +76,10 @@ public class UpYunClient {
|
|
|
|
|
|
private RequestConfig requestConfig;
|
|
|
|
|
|
+ private Boolean test;
|
|
|
+
|
|
|
+ private String testUrl;
|
|
|
+
|
|
|
/**
|
|
|
* 构造函数
|
|
|
*
|
|
@@ -94,6 +99,14 @@ public class UpYunClient {
|
|
|
this.userName = userName;
|
|
|
this.password = password;
|
|
|
this.md5Password = md5(password);
|
|
|
+
|
|
|
+ test = PropertiesUtil.getBoolean("$upyun.test", false);
|
|
|
+ if (test) {
|
|
|
+ testUrl = PropertiesUtil.getString("$upyun.testUrl");
|
|
|
+ if (null == testUrl) {
|
|
|
+ throw new ExamCloudRuntimeException("$upyun.testUrl is not configured.");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -128,6 +141,9 @@ public class UpYunClient {
|
|
|
public String writeFile(String filePath, InputStream in) {
|
|
|
String path = formatPath(filePath);
|
|
|
String url = "http://" + API_DOMAIN + path;
|
|
|
+ if (test) {
|
|
|
+ url = testUrl;
|
|
|
+ }
|
|
|
|
|
|
HttpPut httpPut = new HttpPut(url);
|
|
|
httpPut.setConfig(this.requestConfig);
|