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);
    }
    }

  • 相关阅读:
    完全卸载 Oracle
    Windows 下 Oracle 10g 手工创建数据库
    zip & unzip 命令
    J2EE的13种核心技术规范
    Windows 8发行预览版序列号
    wget百度百科
    Application's Life Cycle
    当前网络存在的安全问题
    Ubuntu 11.10 更换 LightDM 开机登录画面
    tmp文件夹的默认权限
  • 原文地址:https://www.cnblogs.com/yanghongfei/p/7122309.html
Copyright © 2011-2022 走看看