WANG 6 năm trước cách đây
mục cha
commit
df77420ed6

+ 16 - 1
src/main/java/cn/com/qmth/examcloud/web/upyun/UpYunClient.java

@@ -124,6 +124,18 @@ public class UpYunClient {
 	 * @return
 	 */
 	public UpYunSign buildUpYunSign(String filePath) {
+		return buildUpYunSign(filePath, "");
+	}
+
+	/**
+	 * 创建又拍云签名
+	 *
+	 * @author WANGWEI
+	 * @param filePath
+	 * @param md5
+	 * @return
+	 */
+	public UpYunSign buildUpYunSign(String filePath, String md5) {
 		String path = formatPath(filePath);
 		String url = "https://" + API_DOMAIN + path;
 
@@ -131,13 +143,16 @@ public class UpYunClient {
 		String date = getDate();
 		String authorization = null;
 		try {
-			authorization = sign(userName, md5Password, METHOD_PUT, path, date, "", "");
+			authorization = sign(userName, md5Password, METHOD_PUT, path, date, "", md5);
 		} catch (Exception e) {
 			throw new StatusException("100005", "[upyun]. fail to build sign", e);
 		}
 		headers.put(AUTHORIZATION, authorization);
 		headers.put(DATE, date);
 		headers.put(MKDIR, "true");
+		if (StringUtils.isNotBlank(md5)) {
+			headers.put("Content-MD5", md5);
+		}
 
 		UpYunSign sign = new UpYunSign();
 		sign.setUrl(url);