Skip to content

Commit 5f97e6a

Browse files
committed
add base64Decode and fix PutPolicy Expire
1 parent 6b43af2 commit 5f97e6a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/com/qiniu/api/net/EncodeUtils.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ public static byte[] urlsafeEncodeBytes(byte[] src) {
3636
}
3737
return b2;
3838
}
39-
39+
40+
public static byte[] urlsafeBase64Decode(String encoded){
41+
byte[] db64 = Base64.decodeBase64(encoded);
42+
for(int i=0;i<db64.length;i++){
43+
if(db64[i] == '_'){
44+
db64[i] = '/';
45+
}else if(db64[i] == '-'){
46+
db64[i] = '+';
47+
}
48+
}
49+
return db64;
50+
}
51+
4052
public static String urlsafeEncodeString(byte[] src) {
4153
return new String(urlsafeEncodeBytes(src));
4254
}

src/main/java/com/qiniu/api/rs/PutPolicy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ public String token(Mac mac) throws AuthException, JSONException {
7878
if (this.expires == 0) {
7979
this.expires = 3600; // 3600s, default.
8080
}
81+
long orign = this.expires;
8182
this.expires = System.currentTimeMillis() / 1000 + expires;
8283
byte[] data = this.marshal().getBytes();
84+
this.expires = orign;
8385
return DigestAuth.signWithData(mac, data);
8486
}
8587

0 commit comments

Comments
 (0)