• 大小: 77.36MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2022-01-27
  • 语言: Java
  • 标签: fastdfs-java  

资源简介

fastdfs-java源码和maven仓库

资源截图

代码片段和文件信息

package com.leech.fastdfs_demo;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.csource.common.MyException;
import org.csource.common.NameValuePair;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.FileInfo;
import org.csource.fastdfs.StorageClient;
import org.csource.fastdfs.StorageServer;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
import org.junit.After;

import org.junit.Before;

import org.junit.Test;

public class TestFastDfs {

public String conf_filename = “F:\\nuode\\fastdfs-demo\\src\\main\\resources\\fdfs_client.conf“;

public String local_filename = “D:\\stsworkspace\\2.png“;

@Before

public void setUp() throws Exception {

}

@After

public void tearDown() throws Exception {

}

@Test

public void testUpload() {

try {

ClientGlobal.init(conf_filename);

TrackerClient tracker = new TrackerClient();

TrackerServer trackerServer = tracker.getConnection();

StorageServer storageServer = null;

StorageClient storageClient = new StorageClient(trackerServer storageServer);

// NameValuePair nvp = new NameValuePair(“age“ “18“);

NameValuePair nvp[] = new NameValuePair[] {

new NameValuePair(“age“ “18“)

new NameValuePair(“sex“ “male“)

};

String fileIds[] = storageClient.upload_file(local_filename “png“ nvp);

System.out.println(fileIds.length);

System.out.println(“组名:“ + fileIds[0]);

System.out.println(“路径: “ + fileIds[1]);

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} catch (MyException e) {

e.printStackTrace();

}

}

@Test

public void testDownload() {

try {

ClientGlobal.init(conf_filename);

TrackerClient tracker = new TrackerClient();

TrackerServer trackerServer = tracker.getConnection();

StorageServer storageServer = null;

StorageClient storageClient = new StorageClient(trackerServer storageServer);

byte[] b = storageClient.download_file(“group1“ “M00/00/00/wKgBcVllu9CAaVoRAAAfqbjdEdU448.png“);

System.out.println(b);

IOUtils.write(b new FileOutputStream(“D:/“ + UUID.randomUUID().toString() + “.png“));

} catch (Exception e) {

e.printStackTrace();

}

}

@Test

public void testGetFileInfo() {

try {

ClientGlobal.init(conf_filename);

TrackerClient tracker = new TrackerClient();

TrackerServer trackerServer = tracker.getConnection();

StorageServer storageServer = null;

StorageClient storageClient = new StorageClient(trackerServer storageServer);

FileInfo fi = storageClient.get_file_info(“group1“ “M00/00/00/wKgRcFV_08OAK_KCAAAA5fm_sy874.conf“);

System.out.println(fi.getSourceIpAddr());

Syst

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1022  2017-07-12 12:32  fastdfs-java源码\fastdfs-demo\.classpath

     文件        564  2017-07-12 12:32  fastdfs-java源码\fastdfs-demo\.project

     文件        119  2017-07-12 12:32  fastdfs-java源码\fastdfs-demo\.settings\org.eclipse.core.resources.prefs

     文件        243  2017-07-12 12:32  fastdfs-java源码\fastdfs-demo\.settings\org.eclipse.jdt.core.prefs

     文件         90  2017-07-12 12:32  fastdfs-java源码\fastdfs-demo\.settings\org.eclipse.m2e.core.prefs

     文件       1073  2017-07-12 13:11  fastdfs-java源码\fastdfs-demo\pom.xml

     文件       4429  2017-07-12 14:28  fastdfs-java源码\fastdfs-demo\src\main\java\com\leech\fastdfs_demo\TestFastDfs.java

     文件        187  2017-07-12 13:35  fastdfs-java源码\fastdfs-demo\src\main\resources\fdfs_client.conf

     文件        688  2017-07-12 12:32  fastdfs-java源码\fastdfs-demo\src\test\java\com\leech\fastdfs_demo\AppTest.java

     文件       5045  2017-07-12 14:28  fastdfs-java源码\fastdfs-demo\target\classes\com\leech\fastdfs_demo\TestFastDfs.class

     文件        187  2017-07-12 13:35  fastdfs-java源码\fastdfs-demo\target\classes\fdfs_client.conf

     文件        114  2017-07-12 13:11  fastdfs-java源码\fastdfs-demo\target\classes\meta-INF\MANIFEST.MF

     文件        220  2017-07-12 13:11  fastdfs-java源码\fastdfs-demo\target\classes\meta-INF\maven\com.leech\fastdfs-demo\pom.properties

     文件       1073  2017-07-12 13:11  fastdfs-java源码\fastdfs-demo\target\classes\meta-INF\maven\com.leech\fastdfs-demo\pom.xml

     文件       3316  2017-07-12 13:06  fastdfs-java源码\fastdfs-demo\target\fastdfs-demo-0.0.1-SNAPSHOT.jar

     文件        120  2017-07-12 13:06  fastdfs-java源码\fastdfs-demo\target\maven-archiver\pom.properties

     文件         33  2017-07-12 13:05  fastdfs-java源码\fastdfs-demo\target\maven-status\maven-compiler-plugin\compile\default-compile\createdFiles.lst

     文件         68  2017-07-12 13:05  fastdfs-java源码\fastdfs-demo\target\maven-status\maven-compiler-plugin\compile\default-compile\inputFiles.lst

     文件         37  2017-07-12 13:05  fastdfs-java源码\fastdfs-demo\target\maven-status\maven-compiler-plugin\testCompile\default-testCompile\createdFiles.lst

     文件         72  2017-07-12 13:05  fastdfs-java源码\fastdfs-demo\target\maven-status\maven-compiler-plugin\testCompile\default-testCompile\inputFiles.lst

     文件        278  2017-07-12 13:06  fastdfs-java源码\fastdfs-demo\target\surefire-reports\com.leech.fastdfs_demo.AppTest.txt

     文件       4891  2017-07-12 13:06  fastdfs-java源码\fastdfs-demo\target\surefire-reports\TEST-com.leech.fastdfs_demo.AppTest.xml

     文件        631  2017-07-12 13:11  fastdfs-java源码\fastdfs-demo\target\test-classes\com\leech\fastdfs_demo\AppTest.class

     文件   81147350  2017-07-13 14:18  fastdfs-java源码\repository.rar

     目录          0  2017-07-13 14:19  fastdfs-java源码\fastdfs-demo\src\main\java\com\leech\fastdfs_demo

     目录          0  2017-07-13 14:19  fastdfs-java源码\fastdfs-demo\src\test\java\com\leech\fastdfs_demo

     目录          0  2017-07-13 14:19  fastdfs-java源码\fastdfs-demo\target\classes\meta-INF\maven\com.leech\fastdfs-demo

     目录          0  2017-07-13 14:19  fastdfs-java源码\fastdfs-demo\src\main\java\com\leech

     目录          0  2017-07-13 14:19  fastdfs-java源码\fastdfs-demo\src\test\java\com\leech

     目录          0  2017-07-13 14:19  fastdfs-java源码\fastdfs-demo\target\classes\com\leech\fastdfs_demo

............此处省略33个文件信息

评论

共有 条评论

相关资源