zoukankan      html  css  js  c++  java
  • FastDFS使用

    public class FastdfsTest {
    @Test
    public void testUpload()throws Exception{
    // 1、把FastDFS提供的jar包添加到工程中
    // 2、初始化全局配置。加载一个配置文件。
    ClientGlobal.init("C:\Users\Administrator\Workspaces\MyEclipse 10\taotao-manager\taotao-manager-web\src\main\resources\resource\client.conf");
    // 3、创建一个TrackerClient对象。
    TrackerClient trackerClient = new TrackerClient();
    // 4、创建一个TrackerServer对象。
    TrackerServer trackerServer = trackerClient.getConnection();
    // 5、声明一个StorageServer对象,null。
    StorageServer storageServer = null;
    // 6、获得StorageClient对象。
    StorageClient storageClient = new StorageClient(trackerServer, storageServer);
    // 7、直接调用StorageClient对象方法上传文件即可。‪C:UsersAdministratorDesktopaaa.jpg C:\Users\Administrator\Desktop\aaa.jpg ‪C:/Users/Administrator/Desktop/aaa.jpg
    String[] strings = storageClient.upload_file("\C:\Users\Administrator\Desktop\aaa.jpg", "jpg", null);
    for (String string : strings) {
    System.out.println(string);
    }

    }
    @Test
    public void testDfsClient() throws Exception{
    FastDFSClient fastDFSClient = new FastDFSClient("C:\Users\Administrator\Workspaces\MyEclipse 10\taotao-manager\taotao-manager-web\src\main\resources\resource\client.conf");
    String upString=fastDFSClient.uploadFile("\C:\Users\Administrator\Desktop\aa.jpg", "jpg");
    System.out.println(upString);
    }
    }

  • 相关阅读:
    this指向问题
    b继承a的函数
    如何解决跨域问题
    事件冒泡和阻止事件冒泡
    Spring5(二)——IOC
    MySQL基础(四)——
    MySQL基础(二)——常用命令
    MySQL基础(一)——入门
    Linux(二)——常用命令
    Linux(一)——简介
  • 原文地址:https://www.cnblogs.com/yanghongfei/p/7122309.html
Copyright © 2011-2022 走看看