Solon

fastdfs-solon-cloud-plugin

v2.7.5 </> markdown

此插件,由社区成员(暮城留风)贡献

<dependency>
    <groupId>org.noear</groupId>
    <artifactId>fastdfs-solon-cloud-plugin</artifactId>
</dependency>

1、描述

分布式扩展插件。基于 fastdfs 适配的 solon cloud 插件。提供文件存储服务。v1.12.1 后支持

2、云端能力接口

接口说明备注
CloudFileService云端文件服务

3、配置示例

  • 方案1:标准配置 + 内置 fastdfs_def.properties
# 标准配置
solon.cloud.fastdfs.file:
  bucket: "group1"         #默认 group 名称
  endpoint: "10.0.11.201:22122,10.0.11.202:22122" # 相当于 fastdfs.tracker_servers
  secretKey: "FastDFS1234567890"                  # 相当于 fastdfs.http_secret_key

方案2:标准配置 + fastdfs 详细配置

# 标准配置
solon.cloud.fastdfs.file:
  bucket: "group1"         #默认 group 名称
  endpoint: "10.0.11.201:22122,10.0.11.202:22122" # 相当于 fastdfs.tracker_servers
  secretKey: "FastDFS1234567890"                  # 相当于 fastdfs.http_secret_key

# fastdfs 详细配置
fastdfs.charset: UTF-8

fastdfs.connect_timeout_in_seconds: 5
fastdfs.network_timeout_in_seconds: 30

fastdfs.http_anti_steal_token: false
fastdfs.http_tracker_http_port: 80

fastdfs.connection_pool.enabled: true
fastdfs.connection_pool.max_count_per_entry: 500
fastdfs.connection_pool.max_idle_time: 3600
fastdfs.connection_pool.max_wait_time_in_ms: 1000

4、应用示例

public class DemoApp {
    public void main(String[] args) {
        SolonApp app = Solon.start(DemoApp.class, args);

        String key = "test/" + Utils.guid();
        String val = "Hello world!";
        
        //上传媒体
        Result rst = CloudClient.file().put(key, new Media(val));
        
        //获取媒体,并转为字符串
        String val2 = CloudClient.file().get(key).bodyAsString();
    }
}