package com.zdjizhi.tools.general; import com.zdjizhi.common.FlowWriteConfig; import com.zdjizhi.tools.ordinary.MD5Utils; import static com.zdjizhi.common.FlowWriteConfig.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 schemaType, String fileId) { String fileType = null; 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 filename, 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 filename + fileSuffix; } }