WANG vor 6 Jahren
Ursprung
Commit
f11fd5e3a8

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

@@ -79,6 +79,10 @@ public class UpYunClient {
 
 	private String testUrl;
 
+	private String base64Auth = null;
+
+	private boolean unsafe;
+
 	/**
 	 * 构造函数
 	 *
@@ -99,6 +103,10 @@ public class UpYunClient {
 		this.password = password;
 		this.md5Password = md5(password);
 
+		base64Auth = "Basic " + org.apache.commons.codec.binary.Base64
+				.encodeBase64String((userName + password).getBytes());
+		unsafe = true;
+
 		testUrl = PropertiesUtil.getString("$upyun.testUrl");
 	}
 
@@ -148,8 +156,12 @@ public class UpYunClient {
 			String date = getGMTDate();
 			httpPut.addHeader(DATE, date);
 
-			httpPut.addHeader(AUTHORIZATION, UpYunUtils
-					.sign(METHOD_PUT, date, path, userName, this.md5Password, null).trim());
+			if (unsafe) {
+				httpPut.addHeader(AUTHORIZATION, base64Auth);
+			} else {
+				httpPut.addHeader(AUTHORIZATION, UpYunUtils
+						.sign(METHOD_PUT, date, path, userName, this.md5Password, null).trim());
+			}
 
 			httpPut.addHeader(MKDIR, "true");