wangwei hace 6 años
padre
commit
e7ddab83e7

+ 5 - 2
examcloud-exchange-inner-service/src/main/java/cn/com/qmth/examcloud/exchange/inner/service/upyun/UpYunClient.java

@@ -83,6 +83,8 @@ public class UpYunClient {
 
 	private boolean unsafe;
 
+	private String domain;
+
 	/**
 	 * 构造函数
 	 *
@@ -90,7 +92,7 @@ public class UpYunClient {
 	 * @param userName
 	 * @param password
 	 */
-	public UpYunClient(String bucketName, String userName, String password) {
+	public UpYunClient(String bucketName, String userName, String password, String domain) {
 		PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
 		cm.setMaxTotal(1000);
 		httpclient = HttpClients.custom().setConnectionManager(cm).disableAutomaticRetries()
@@ -101,6 +103,7 @@ public class UpYunClient {
 		this.bucketName = bucketName;
 		this.userName = userName;
 		this.password = password;
+		this.domain = domain;
 		this.md5Password = md5(password);
 
 		base64Auth = "Basic " + org.apache.commons.codec.binary.Base64
@@ -190,7 +193,7 @@ public class UpYunClient {
 					+ " ms.");
 		}
 
-		String fileUrl = "http://" + bucketName + ".b0.upaiyun.com" + filePath;
+		String fileUrl = this.domain + filePath;
 		return new UpYunPathInfo(fileUrl, filePath);
 	}
 

+ 5 - 1
examcloud-exchange-inner-service/src/main/java/cn/com/qmth/examcloud/exchange/inner/service/upyun/UpyunSiteManager.java

@@ -53,6 +53,7 @@ public class UpyunSiteManager {
 			String bucketName = PropertyHolder.getString("$upyun.site." + upyunId + ".bucketName");
 			String userName = PropertyHolder.getString("$upyun.site." + upyunId + ".userName");
 			String password = PropertyHolder.getString("$upyun.site." + upyunId + ".password");
+			String domain = PropertyHolder.getString("$upyun.site." + upyunId + ".domain");
 
 			if (StringUtils.isBlank(bucketName)) {
 				throw new StatusException("520002",
@@ -66,8 +67,11 @@ public class UpyunSiteManager {
 				throw new StatusException("520004",
 						"password is not configured. upyunId=" + upyunId);
 			}
+			if (StringUtils.isBlank(domain)) {
+				throw new StatusException("520004", "domain is not configured. upyunId=" + upyunId);
+			}
 
-			UpYunClient upYunClient = new UpYunClient(bucketName, userName, password);
+			UpYunClient upYunClient = new UpYunClient(bucketName, userName, password, domain);
 
 			CLIENT_HOLDERS.put(upyunSite.getId(), upYunClient);
 		}