Clean code
This commit is contained in:
parent
7c9a63c4dc
commit
90ff5c9376
|
|
@ -460,7 +460,7 @@ public class API {
|
|||
public Object[] proxySub(Map<String, String> params) throws Exception {
|
||||
String fileId = params.get("file_id");
|
||||
Response res = OkHttp.newCall(getDownloadUrl(fileId), getHeaderAuth());
|
||||
byte[] body = Utils.getUTF8(res.body().bytes());
|
||||
byte[] body = Utils.toUtf8(res.body().bytes());
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "application/octet-stream";
|
||||
|
|
|
|||
|
|
@ -56,12 +56,8 @@ public class Utils {
|
|||
return Arrays.equals(bytes, newBytes);
|
||||
}
|
||||
|
||||
public static byte[] getUTF8(byte[] bytes) throws Exception {
|
||||
if (isGBK(bytes)) {
|
||||
return new String(bytes, Charset.forName("GBK")).getBytes("UTF-8");
|
||||
} else {
|
||||
return bytes;
|
||||
}
|
||||
public static byte[] toUtf8(byte[] bytes) throws Exception {
|
||||
return isGBK(bytes) ? new String(bytes, Charset.forName("GBK")).getBytes("UTF-8") : bytes;
|
||||
}
|
||||
|
||||
public static boolean isSub(String ext) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue