@RequestMapping(value = "/show", method = RequestMethod.GET) public String show(String groupId, String fileId,Model model) throws Exception { // 通过ClassPath路径获取要使用的配置文件 ClassPathResource classPathResource = new ClassPathResource( "fastdfs_client.conf"); // 进行客户端访问的整体配置,需要知道配置文件的完整路径 ClientGlobal.init(classPathResource.getClassLoader() .getResource("fastdfs_client.conf").getPath()); // FastDFS的核心操作在于tracker处理上,所以此时需要定义Tracker客户端 TrackerClient trackerClient = new TrackerClient(); // 定义TrackerServer的配置信息 TrackerServer trackerServer = trackerClient.getConnection(); int ts = (int) (System.currentTimeMillis() / 1000);// 时间参考 StringBuffer fileUrl = new StringBuffer(); fileUrl.append("http://"); fileUrl.append("fastdfs-tracker"); fileUrl.append("/" + groupId + "/").append(fileId); fileUrl.append("?token=").append( ProtoCommon.getToken(fileId, ts, ClientGlobal.g_secret_key)); fileUrl.append("&ts=").append(ts); System.out.println(fileUrl); trackerServer.close(); model.addAttribute("image", fileUrl) ; return "upload_show" ; }
token = ProtoCommon.getToken(file_id, ts, ClientGlobal.g_secret_key); file_url += "?token=" + token + "&ts=" + ts;
token = ProtoCommon.getToken(appender_file_id, ts, ClientGlobal.g_secret_key); file_url += "?token=" + token + "&ts=" + ts;
token = ProtoCommon.getToken(file_id, ts, ClientGlobal.g_secret_key); file_url += "?token=" + token + "&ts=" + ts;
token = ProtoCommon.getToken(file_id, ts, ClientGlobal.g_secret_key); file_url += "?token=" + token + "&ts=" + ts;