分布式文件系统研究-测试-文件下载测试
生活随笔
收集整理的這篇文章主要介紹了
分布式文件系统研究-测试-文件下载测试
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文件下載
package com.learn.test.fastdfs;import org.csource.common.MyException; import org.csource.fastdfs.*; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner;import java.io.File; import java.io.FileOutputStream; import java.io.IOException;/*** @author Administrator* @version 1.0**/ @SpringBootTest @RunWith(SpringRunner.class) public class TestFastDFS {//下載文件@Testpublic void testDownload(){try {//加載fastdfs-client.properties配置文件ClientGlobal.initByProperties("config/fastdfs-client.properties");//定義TrackerClient,用于請求TrackerServerTrackerClient trackerClient = new TrackerClient();//連接trackerTrackerServer trackerServer = trackerClient.getConnection();//獲取StroageStorageServer storeStorage = trackerClient.getStoreStorage(trackerServer);//創(chuàng)建stroageClientStorageClient1 storageClient1 = new StorageClient1(trackerServer,storeStorage);//下載文件//文件idString fileId = "group1/M00/00/01/wKhlQVuhU3eADb4pAAAawU0ID2Q159.png";byte[] bytes = storageClient1.download_file1(fileId);//使用輸出流保存文件FileOutputStream fileOutputStream = new FileOutputStream(new File("c:/logo.png"));fileOutputStream.write(bytes);} catch (IOException e) {e.printStackTrace();} catch (MyException e) {e.printStackTrace();}}}?
總結(jié)
以上是生活随笔為你收集整理的分布式文件系统研究-测试-文件下载测试的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 分布式文件系统研究-测试-上传文件测试
- 下一篇: 分布式文件系统研究-搭建图片服务虚拟主机