浏览代码

FastDFS配置修改

gaodm 6 年之前
父节点
当前提交
e94704e565

+ 8 - 0
config-server/src/main/resources/shared/icssman-service-dev.yml

@@ -98,3 +98,11 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122
+

+ 9 - 0
config-server/src/main/resources/shared/icssman-service-local.yml

@@ -98,3 +98,12 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122
+
+

+ 8 - 0
config-server/src/main/resources/shared/icssman-service-pro.yml

@@ -98,3 +98,11 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122
+

+ 7 - 0
config-server/src/main/resources/shared/icssman-service-test.yml

@@ -98,3 +98,10 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.241:22122

+ 0 - 7
gateway-service/src/main/resources/fdfs_client.conf

@@ -1,7 +0,0 @@
-connect_timeout = 60
-network_timeout = 60
-charset = UTF-8
-http.tracker_http_port = 8080
-http.anti_steal_token = no
-
-tracker_server = 192.168.2.236:22122

+ 0 - 14
icssman-service/src/main/java/com/diagbot/client/fastdfs/FastDFSClient.java

@@ -1,7 +1,5 @@
 package com.diagbot.client.fastdfs;
 
-import com.diagbot.util.StringUtil;
-import org.apache.commons.lang3.StringUtils;
 import org.csource.common.NameValuePair;
 import org.csource.fastdfs.ClientGlobal;
 import org.csource.fastdfs.FileInfo;
@@ -11,7 +9,6 @@ import org.csource.fastdfs.StorageServer;
 import org.csource.fastdfs.TrackerClient;
 import org.csource.fastdfs.TrackerServer;
 import org.slf4j.LoggerFactory;
-import org.springframework.core.io.ClassPathResource;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -25,15 +22,6 @@ import java.io.InputStream;
 public class FastDFSClient {
     private static org.slf4j.Logger logger = LoggerFactory.getLogger(FastDFSClient.class);
 
-    static {
-        try {
-            String filePath = new ClassPathResource("fdfs_client.conf").getFile().getAbsolutePath();
-            ClientGlobal.init(filePath);
-        } catch (Exception e) {
-            logger.error("FastDFS Client Init Fail!", e);
-        }
-    }
-
     public static String[] upload(FastDFSFile file) {
         logger.info("File Name: " + file.getName() + "File Length:" + file.getContent().length);
 
@@ -46,8 +34,6 @@ public class FastDFSClient {
         try {
             storageClient = getTrackerClient();
             uploadResults = storageClient.upload_file(file.getContent(), file.getExt(), meta_list);
-            logger.info("storageClient:"+storageClient.toString());
-            logger.info("uploadResults:"+ StringUtils.join(uploadResults,','));
         } catch (IOException e) {
             logger.error("IO Exception when uploadind the file:" + file.getName(), e);
         } catch (Exception e) {

+ 49 - 0
icssman-service/src/main/java/com/diagbot/config/FastDFSConfigurer.java

@@ -0,0 +1,49 @@
+package com.diagbot.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.csource.fastdfs.ClientGlobal;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Properties;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2019/3/1 14:15
+ */
+@Configuration
+@Slf4j
+public class FastDFSConfigurer {
+    @Value("${fastdfs.connect_timeout_in_seconds}")
+    private String connectTimeout;
+    @Value("${fastdfs.network_timeout_in_seconds}")
+    private String networkTimeout;
+    @Value("${fastdfs.charset}")
+    private String charset;
+    @Value("${fastdfs.http_tracker_http_port}")
+    private String httpTrackerHttpPort;
+    @Value("${fastdfs.http_anti_steal_token}")
+    private String httpAntiStealToken;
+    @Value("${fastdfs.tracker_servers}")
+    private String trackerServers;
+
+    @Bean
+    public Integer fastDFSInit(){
+        try {
+            Properties props = new Properties();
+            props.put(ClientGlobal.PROP_KEY_CONNECT_TIMEOUT_IN_SECONDS, connectTimeout);
+            props.put(ClientGlobal.PROP_KEY_NETWORK_TIMEOUT_IN_SECONDS, networkTimeout);
+            props.put(ClientGlobal.PROP_KEY_CHARSET, charset);
+            props.put(ClientGlobal.PROP_KEY_HTTP_TRACKER_HTTP_PORT, httpTrackerHttpPort);
+            props.put(ClientGlobal.PROP_KEY_HTTP_ANTI_STEAL_TOKEN, httpAntiStealToken);
+            props.put(ClientGlobal.PROP_KEY_TRACKER_SERVERS, trackerServers);
+            ClientGlobal.initByProperties(props);
+
+        } catch (Exception e) {
+            log.error("FastDFS Client Init Fail!", e);
+        }
+        return 1;
+    }
+}

+ 0 - 7
icssman-service/src/main/resources/fdfs_client.conf

@@ -1,7 +0,0 @@
-connect_timeout = 60
-network_timeout = 60
-charset = UTF-8
-http.tracker_http_port = 8080
-http.anti_steal_token = no
-
-tracker_server = 192.168.2.236:22122