|
@@ -119,13 +119,11 @@ public class DataService {
|
|
|
* @param number
|
|
|
*/
|
|
|
public void saveAnnex(Map <String,String> map, String filePath) {
|
|
|
- String newUrl = filePath.replaceAll("\\\\", "/") ;
|
|
|
- String fileNameStr[] = newUrl.split("/");
|
|
|
+ String fileNameStr[] = filePath.split("/");
|
|
|
String fileName = fileNameStr[fileNameStr.length-1];
|
|
|
- String fileStorePath =getFileWithUrl(newUrl, fileName);
|
|
|
+ String fileStorePath =getFileWithUrl(filePath, fileName);
|
|
|
File file =new File(fileStorePath);
|
|
|
- String eTag = getFileMd5(file);
|
|
|
- String key = PropKit.get("institution_id")+"/"+eTag+".pdf";
|
|
|
+ String key = PropKit.get("institution_id")+"/"+fileName;
|
|
|
|
|
|
Boolean eBoolean = OSS_CLIENT.doesObjectExist(PropKit.get("oss_bucketName"), key);
|
|
|
if (!eBoolean) {
|
|
@@ -141,33 +139,7 @@ public class DataService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private String getFileMd5(File file) {
|
|
|
- StringBuffer sb = new StringBuffer("");
|
|
|
- try {
|
|
|
- MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
- md.update(FileUtils.readFileToByteArray(file));
|
|
|
- byte b[] = md.digest();
|
|
|
- int d;
|
|
|
- for (int i = 0; i < b.length; i++) {
|
|
|
- d = b[i];
|
|
|
- if (d < 0) {
|
|
|
- d = b[i] & 0xff;
|
|
|
- // 与上一行效果等同
|
|
|
- // i += 256;
|
|
|
- }
|
|
|
- if (d < 16)
|
|
|
- sb.append("0");
|
|
|
- sb.append(Integer.toHexString(d));
|
|
|
- }
|
|
|
- System.out.println(sb);
|
|
|
-
|
|
|
- } catch (NoSuchAlgorithmException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return sb.toString();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
public static String postWithParameters(String url, Map<String, String> map) {
|