* 适配上传策略(putPolicy)

This commit is contained in:
Joshua Yin 2020-03-21 01:29:49 +08:00
parent 96f1a3595d
commit 0183e1b0ba
2 changed files with 23 additions and 3 deletions

View File

@ -21,6 +21,7 @@ public class AuthRequest {
private String content_md5 = "";
private String date = "";
private String optional;
private String put_policy;
public String getMethod() {
return method;
@ -50,6 +51,10 @@ public class AuthRequest {
return optional;
}
public String getPut_policy() {
return put_policy;
}
@Override
public String toString() {
return new Gson().toJson(this);

View File

@ -33,15 +33,30 @@ public class UfileAuthService {
signData.append(request.getDate() + "\n");
signData.append("/" + request.getBucket());
signData.append("/" + request.getKey());
if (request.getPut_policy() != null && !request.getPut_policy().isEmpty()) {
signData.append(request.getPut_policy());
}
String signature = signature(privateKey, signData.toString());
return "UCloud " + publicKey + ":" + signature;
} catch (ValidatorException e) {
StringBuilder res = new StringBuilder("UCloud ")
.append(publicKey)
.append(":")
.append(signature);
if (request.getPut_policy() != null && !request.getPut_policy().isEmpty()) {
res.append(":").append(request.getPut_policy());
}
return res.toString();
} catch (
ValidatorException e) {
return e.getMessage();
} catch (Exception e) {
} catch (
Exception e) {
return e.getMessage();
}
}
public String calculatePrivateUrlAuthroization(AuthPrivateUrlRequest request) {