1. 程式人生 > 實用技巧 >3 測試docker檔案上傳功能

3 測試docker檔案上傳功能

上一篇我們在docker中安裝好了fastdfs,本篇就來上傳一個圖片進行測試

建立springboot專案,新增依賴

        <dependency>
            <groupId>net.oschina.zcx7878</groupId>
            <artifactId>fastdfs-client-java</artifactId>
            <version>1.27.0.0</version>
        </dependency>

 更改地址

書寫測試類

    @Test
    void contextLoads() throws IOException, MyException {

        ClientGlobal.initByProperties("fastdfs-client.properties");
        TrackerClient trackerClient = new TrackerClient();
        TrackerServer trackerServer = trackerClient.getConnection();
        StorageServer storageServer=null;
        StorageClient1 client1 = new StorageClient1(trackerServer, storageServer);
        NameValuePair pairs[]=null;
        String fileId = client1.upload_file1("G:\\a.jpg", "jpg", pairs);
        System.out.println(fileId);

    }

  執行後返回

檢視檔案

訪問檔案