fastdfs-client使用教程
程序员文章站
2022-05-03 09:59:48
FastDfs客户端使用文档fastdfs-client支持框架fastdfs-client目前支持的框架有springboot1.x 、springboot2.x、springmvc添加fastdfs-client依赖springboot项目项目pom.xml文件中增加jar包依赖com.msun fastdfs-client-springboot<...
FastDfs客户端使用文档
fastdfs-client支持框架
fastdfs-client目前支持的框架有springboot1.x 、springboot2.x、springmvc
添加fastdfs-client依赖
springboot项目
项目pom.xml文件中增加jar包依赖
<dependency>
<groupId>com.msun</groupId>
<artifactId>fastdfs-client-springboot</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
项目启动类增加注解支持
@SpringBootApplication
@EnableFastDfsClient
public class BailingServiceFaceverifyApplication {
public static void main(String[] args) {
SpringApplication.run(BailingServiceFaceverifyApplication.class, args);
}
}
application.properties文件中增加fastdfs相关配置文件
## fastdfs-client.properties
fastdfs.connect_timeout_in_seconds = 5
fastdfs.network_timeout_in_seconds = 30
fastdfs.charset = UTF-8
fastdfs.http_anti_steal_token = false
fastdfs.http_secret_key = FastDFS1234567890
fastdfs.http_tracker_http_port = 80
fastdfs.tracker_servers = 185.245.40.70:22122
## Whether to open the connection pool, if not, create a new connection every time
fastdfs.connection_pool.enabled = true
## max_count_per_entry: max connection count per host:port , 0 is not limit
fastdfs.connection_pool.max_count_per_entry = 500
## connections whose the idle time exceeds this time will be closed, unit: second, default value is 3600
fastdfs.connection_pool.max_idle_time = 3600
## Maximum waiting time when the maximum number of connections is reached, unit: millisecond, default value is 1000
fastdfs.connection_pool.max_wait_time_in_ms = 1000
在业务代码中直接注入FastDfsClient类即可调用相关上传下载等方法
@Autowired
private FastDfsClient fastDfsClient;
springmvc项目
项目pom.xml文件中增加jar包依赖
<dependency>
<groupId>com.msun</groupId>
<artifactId>fastdfs-client-springmvc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
在类路径下创建fdfs_client.conf文件,内容为
## fastdfs-client.properties
fastdfs.connect_timeout_in_seconds = 5
fastdfs.network_timeout_in_seconds = 30
fastdfs.charset = UTF-8
fastdfs.http_anti_steal_token = false
fastdfs.http_secret_key = FastDFS1234567890
fastdfs.http_tracker_http_port = 80
fastdfs.tracker_servers = 185.245.40.70:22122
## Whether to open the connection pool, if not, create a new connection every time
fastdfs.connection_pool.enabled = true
## max_count_per_entry: max connection count per host:port , 0 is not limit
fastdfs.connection_pool.max_count_per_entry = 500
## connections whose the idle time exceeds this time will be closed, unit: second, default value is 3600
fastdfs.connection_pool.max_idle_time = 3600
## Maximum waiting time when the maximum number of connections is reached, unit: millisecond, default value is 1000
fastdfs.connection_pool.max_wait_time_in_ms = 1000
在业务代码中直接通过FastDfsClient类即可调用相关上传下载等方法
本文地址:https://blog.csdn.net/springdata_/article/details/107247163
上一篇: 全新任务管理器!Win10新功能曝光 秒杀死应用进程了
下一篇: SpringMVC初探01