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