• go-fastdfs安装(国产分布式文件系统)


    1. 开源协议: Unlicense
    2. 官网地址: https://sjqzhang.github.io/go-fastdfs/#vision
    3. 安装:
    wget --no-check-certificate  https://github.com/sjqzhang/go-fastdfs/releases/download/v1.3.1/fileserver -O fileserver && chmod +x fileserver && ./fileserver
    
    • 1
    1. 上传 文件(基于solon)
    @ApiOperation("文件上传")
    @Mapping("/upload")
    public String upload(UploadedFile file){
        String result = "";
        InputStreamResource isr = new InputStreamResource(file.getContent(),
                file.getName());
        Map<String, Object> params = new HashMap<>();
        params.put("file", isr);
        params.put("path", "86501729");
        params.put("output", "json");
        String resp = HttpUtil.post("http://192.168.1.156:8080/upload", params);
        Console.log("resp: {}", resp);
        result = resp;
        return resp;
    }
    
    @ApiOperation("下载")
    @Mapping("download")
    public void down(Context ctx) throws IOException {
        File file = new File("http://192.168.1.156:8080/group1/zkcy/screenshot-20230217-112719.png");
        ctx.outputAsFile(file);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    1. web页面安装

      1. 下载地址: https://github.com/perfree/go-fastdfs-web/releases
      2. 默认端口8088,修改默认端口号更改config/application.yml即可
      3. 如go-fastdfs开启了按组管理,则需要填写组名,反之不用填写
      4. 进入安装页填写集群地址时,该地址需要在go-fastdfs配置文件配置管理ip白名单,否则获取不到数据!
      5. 文件列表功能需要go-fastdfs服务版本在v1.2.8以上
      6. 遇到获取不到信息的功能,先试一下本地调用go-fastdfs接口看是否能获取到
    2. 命令介绍

    	1.运行
    	./goFastDfsWeb.sh start
    	2.查看运行状态
    	./goFastDfsWeb.sh status
    	3.重新启动
    	./goFastDfsWeb.sh restart
    	4.停止
    	./goFastDfsWeb.sh stop
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    1. 如遇到-bash: ./goFastDfsWeb.sh: /bin/bash^M: 坏的解释器: 没有那个文件或目录错误,则执行以下命令再运行

      sed -i 's/\r//' ./goFastDfsWeb.sh
      
      • 1
    2. web界面配置

      1. 首次运行时,需要填初始化服务信息 在cfg.json中添加白名单如下图
      2. 1. cfg.json 在安装路径下的conf文件夹下
        
        • 1
      3. 在这里插入图片描述
      4. 初始化时如无分组 请勿填写 仅需填写 ip地址即可 也就是中间的一行
      5. 填写用户名密码即可
      6. 账号信息 zkcy qwer123!
      7. 页面如下 http://192.168.1.156:8088/login
      8. 在这里插入图片描述
    3. 开启上传验证在这里插入图片描述

    4. 在cfg.json中添加 验证url 在这里插入图片描述

    5. 代码示例

      @ApiOperation("文件上传")
      @Mapping("/upload")
      public String upload(UploadedFile file,String authToken){
          InputStreamResource isr = new InputStreamResource(file.getContent(),
                  file.getName());
          Map<String, Object> params = new HashMap<>();
          params.put("file", isr);
          params.put("path", "zkcy");
          params.put("output", "json");
          params.put("auth_token", authToken);
          String resp = HttpUtil.post("http://192.168.1.156:8080/upload", params);
          Console.log("resp: {}", resp);
          return resp;
      }
      //cfg.json中配置的验证url 校验token
      @Post
      @ApiOperation("验证")
      @Mapping("/auth")
      public String auth(String auth_token) throws Exception {
          if ("ok".equals(auth_token)){
              return "ok";
          }else {
              return "fail";
          }
      }
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
  • 相关阅读:
    计算机毕业设计PySpark+大模型农产品推荐系统 农产品爬虫 农产品商城 农产品大数据 农产品数据分析可视化 PySpark Hadoop
    WebGIS开发教程:geojson
    Tomcat设置IP黑名单和白名单server.xml
    ARM功耗管理之唤醒源与组合唤醒源
    2.4 Sample Moments and Hypothesis Tests
    Docker 镜像源配置
    Java数据结构与算法:最短路径与Dijstra算法实现
    【15分】E. DS森林叶子编码
    基于改进螺旋更新位置模型的鲸鱼优化算法-附代码
    Python中的设计模式 -- 单例
  • 原文地址:https://blog.csdn.net/weixin_38301116/article/details/133926432