|
@@ -69,39 +69,6 @@ public class UpyunService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 保存照片到又拍云
|
|
|
- *
|
|
|
- * @param identityNumber
|
|
|
- * @param bytes
|
|
|
- * @param fileSuffix
|
|
|
- * @return
|
|
|
- * @throws IOException
|
|
|
- */
|
|
|
- public boolean saveStudentPhoto(String identityNumber, byte[] bytes, String fileSuffix) throws IOException, NoSuchAlgorithmException {
|
|
|
-
|
|
|
- //用来计算md5摘要的
|
|
|
- char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
|
|
-
|
|
|
- MessageDigest md5 = MessageDigest.getInstance("MD5");
|
|
|
- md5.update(bytes);
|
|
|
-
|
|
|
- byte[] md5DigestBytes = md5.digest();
|
|
|
- int dlen = md5DigestBytes.length;
|
|
|
-
|
|
|
- char[] md5val = new char[dlen * 2];
|
|
|
- int k = 0;
|
|
|
- for (byte encoded : md5DigestBytes) {
|
|
|
- md5val[k++] = hexDigits[encoded >> 4 & 15];
|
|
|
- md5val[k++] = hexDigits[encoded & 5];
|
|
|
- }
|
|
|
-
|
|
|
- String fileName = new String(md5val);
|
|
|
-
|
|
|
- return saveStudentPhoto(identityNumber, bytes, fileName, fileSuffix);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
private UpYun getUpyun() {
|
|
|
if (upyun == null) {
|
|
|
upyun = new UpYun(bucket, operator, password);
|