mirror of
https://github.com/ucloud/ufile-sdk-auth-server.git
synced 2025-04-06 05:25:45 +08:00
* 适配上传策略(putPolicy)
This commit is contained in:
parent
96f1a3595d
commit
0183e1b0ba
@ -21,6 +21,7 @@ public class AuthRequest {
|
|||||||
private String content_md5 = "";
|
private String content_md5 = "";
|
||||||
private String date = "";
|
private String date = "";
|
||||||
private String optional;
|
private String optional;
|
||||||
|
private String put_policy;
|
||||||
|
|
||||||
public String getMethod() {
|
public String getMethod() {
|
||||||
return method;
|
return method;
|
||||||
@ -50,6 +51,10 @@ public class AuthRequest {
|
|||||||
return optional;
|
return optional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPut_policy() {
|
||||||
|
return put_policy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new Gson().toJson(this);
|
return new Gson().toJson(this);
|
||||||
|
@ -33,15 +33,30 @@ public class UfileAuthService {
|
|||||||
signData.append(request.getDate() + "\n");
|
signData.append(request.getDate() + "\n");
|
||||||
signData.append("/" + request.getBucket());
|
signData.append("/" + request.getBucket());
|
||||||
signData.append("/" + request.getKey());
|
signData.append("/" + request.getKey());
|
||||||
|
if (request.getPut_policy() != null && !request.getPut_policy().isEmpty()) {
|
||||||
|
signData.append(request.getPut_policy());
|
||||||
|
}
|
||||||
|
|
||||||
String signature = signature(privateKey, signData.toString());
|
String signature = signature(privateKey, signData.toString());
|
||||||
|
|
||||||
return "UCloud " + publicKey + ":" + signature;
|
StringBuilder res = new StringBuilder("UCloud ")
|
||||||
} catch (ValidatorException e) {
|
.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();
|
return e.getMessage();
|
||||||
} catch (Exception e) {
|
} catch (
|
||||||
|
Exception e) {
|
||||||
return e.getMessage();
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String calculatePrivateUrlAuthroization(AuthPrivateUrlRequest request) {
|
public String calculatePrivateUrlAuthroization(AuthPrivateUrlRequest request) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user