Maven_Fastdfs 实例
来源:互联网 发布:最短路算法 编辑:程序博客网 时间:2024/06/04 23:01
Linux_FastDFS 安装笔记
Linux_FastDFS 集群安装笔记
org.csource.common和org.csource.fastdfs两个包来自于fastdfs-client-java。
fdfs_client.conf
connect_timeout = 2network_timeout = 30charset = UTF-8http.tracker_http_port = 8080http.anti_steal_token = nohttp.secret_key = FastDFS1234567890tracker_server = 192.168.216.140:22122
FastdfsTest.java
package com.demo.fastdfs.test;import java.io.IOException;import org.csource.common.MyException;import org.csource.common.NameValuePair;import org.csource.fastdfs.ClientGlobal;import org.csource.fastdfs.StorageClient1;import org.csource.fastdfs.TrackerClient;import org.csource.fastdfs.TrackerServer;import org.junit.After;import org.junit.Before;import org.junit.Test;public class FastdfsTest { private static final String upload_file = "D:\\tortoise.jpg"; private StorageClient1 client; private TrackerServer trackerServer; @Before public void init() throws IOException, MyException { ClientGlobal.init("fdfs_client.conf"); trackerServer = new TrackerClient().getConnection(); client = new StorageClient1(trackerServer, null); } @Test public void fdfs() throws IOException, MyException { NameValuePair[] metaList = new NameValuePair[1]; metaList[0] = new NameValuePair("fileName", upload_file); // 上传文件 String fileId = client.upload_file1(upload_file, null, metaList); System.out.println("upload success. file id is: " + fileId); // 下载文件 byte[] result = client.download_file1(fileId); System.out.println("download result is: " + result.length); // 删除文件 int code = client.delete_file1(fileId); System.out.println("0 for success, none zero for fail (error code): " + code); closeFastdfs(); } @After public void closeFastdfs() throws IOException { if (trackerServer != null) { trackerServer.close(); } }}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.demo</groupId> <artifactId>maven-fastdfs</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies></project>
maven-fastfds 实例源码
阅读全文
0 0
- Maven_Fastdfs 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- 实例
- redis中的事务
- android中控件的测量
- 超级淘为什么能在众多新零售导购平台崛起,并深受大家欢迎
- jsp html input="file" 浏览时只显示指定文件类型 xls、xlsx、csv
- ArrayList与List
- Maven_Fastdfs 实例
- chmod命令高级篇( SetUID与SetGID标识位)
- 棋盘问题
- C#泛型示例
- 程序员_你和高考隔了几年?
- easyui combobox插入一条数据到选项中
- spring基于xml定时器
- EOS Platform7.6的流程引擎可以提供查询回退记录的API
- (String)强制转换、toString()和String.valueOf()的区别