packageutil;importjava.io.ByteArrayInputStream;importjava.io.File;importjava.io.FileInputStream;importjava.io.IOException;importjava.io.InputStream;importorg.apache.commons.lang3.StringUtils;importorg.apache.log4j.Logger;importorg.csource.common.NameValuePair;importorg.csource.fastdfs.ClientGlobal;importorg.csource.fastdfs.StorageClient1;importorg.csource.fastdfs.StorageServer;importorg.csource.fastdfs.TrackerClient;importorg.csource.fastdfs.TrackerGroup;importorg.csource.fastdfs.TrackerServer;/***
* 系统名称:
* 模块名称:
* 中文类名:FastDFS分布式文件系统操作客户端
* 概要说明:FastDFS分布式文件系统操作客户端
*@authorbhz
*@since2013年11月10日*/
public classFastDFSClientUtils {private static final String CONF_FILENAME = Thread.currentThread().getContextClassLoader().getResource("fastdfs_client.conf").getPath();private static Logger logger = Logger.getLogger(FastDFSClientUtils.class);private staticTrackerClient trackerClient;//加载文件
static{try{
ClientGlobal.init(CONF_FILENAME);
TrackerGroup trackerGroup=ClientGlobal.g_tracker_group;
trackerClient= newTrackerClient(trackerGroup);
}catch(Exception e) {
logger.error(e);
}
}/*** 方法名称:上传方法
* 概要说明:
*@paramfile 文件
*@parampath 路径
*@return上传成功返回id,失败返回null*/
public staticString upload(File file, String path) {
TrackerServer trackerServer= null;