package com.zdjizhi.utils.general; import com.zdjizhi.common.FlowWriteConfig; import com.zdjizhi.utils.ordinary.MD5Utils; import static com.zdjizhi.utils.system.FlowWriteConfigurations.judgeFileType; /** * 文件字段操作工具 */ public class FileEdit { public static String getFileUploadUrl(long cfgId,String sIp,int sPort,String dIp,int dPort,long foundTime,String account,String domain, String urlValue,String schemaType,String fileId){ String fileType = null; if (judgeFileType(getFileType(urlValue))){ fileType = getFileType(urlValue); }else { if (schemaType.equals("HTTP")){ fileType = "html"; } if (schemaType.equals("MAIL")){ fileType = "eml"; } } return "http://"+ FlowWriteConfig.OOS_SERVERS+"/v3/upload?cfg_id="+cfgId+"&file_id="+fileId+"&file_type="+fileType+"&found_time="+foundTime+"&s_ip="+sIp+"&s_port="+sPort+"&d_ip="+dIp+"&d_port="+dPort+"&domain="+domain+"&account="+account; } public static String getFileDownloadUrl(String fileId){ return "http://"+ FlowWriteConfig.OOS_SERVERS+"/v3/download?file_id="+fileId; } public static String getFileType(String url){ String[] split = url.split("\\."); return split[split.length-1]; } public static String getFileId(String url,String fileSuffix) throws Exception { String[] arr = url.split("/"); String filename = arr[arr.length-1].substring(0,arr[arr.length-1].lastIndexOf("_")); String prefix = MD5Utils.md5Encode(filename); // String suffix = arr[arr.length-1].substring(arr[arr.length-1].lastIndexOf("_"),arr[arr.length-1].lastIndexOf(".")); return prefix+fileSuffix; } }