关于fdfsjava的信息

博主:adminadmin 2023-01-07 20:15:08 814

今天给各位分享fdfsjava的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

fastDFS有监控机制么?

回复 1# 基本上都有吧。tracker server提供了监控接口。已经提供了C、PHP和Java API。可以看一下C监控程序fdfs_monitor的输出。

fastdfs在java中上传和查看没问题,Java调用删除的时候报错:2,错误信息:找不到节点或文件。求大神解决

你好!

这个异常的原因很大程度上是IP地址不一致。

检查一下IP的配置吧。

希望对你有帮助!

FastDFS 和 Nginx 整合

Centos 7 安装 FastDFS

$ cd /usr/java

$ wget

$ tar -zxvf fastdfs-nginx-module-1.20.tar.gz

$ mv fastdfs-nginx-module-1.20 fastdfs-nginx-module

$ vi fastdfs-nginx-module/src/config

致命错误:common_define.h:没有那个文件或目录 在这里折磨了好久好久~

CentOS 7 安装 Nginx

注意:使用安装包源码安装, $ make 前,在 ./configure 时,加上 --add-module=/usr/java/fastdfs-nginx-module/src 参数

$ cp /usr/java/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

$ vi /etc/fdfs/mod_fastdfs.conf

$ cd /usr/java/fastdfs-5.11/conf/

$ cp -f http.conf mime.types /etc/fdfs/

$ ln -s /home/fastdfs/fdfs_storage/data/ /home/fastdfs/fdfs_storage/data/M00

$ vi /usr/java/nginx/conf/nginx.conf

$ /usr/bin/fdfs_test /usr/java/fastdfs/conf/client.conf upload /usr/java/1.PNG

访问路径记得加上端口:

fastdfs java 怎么使用

import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.InputStream;

import java.util.HashMap;

import java.util.Map;

import org.apache.commons.io.FilenameUtils;

import org.apache.log4j.Logger;

import org.csource.common.MyException;

import org.csource.fastdfs.ClientGlobal;

import org.csource.fastdfs.StorageClient;

import org.csource.fastdfs.TrackerClient;

import org.csource.fastdfs.TrackerServer;

import org.springframework.core.io.ClassPathResource;

import org.springframework.core.io.Resource;

public class FastdfsUtils {

    /** fdfs初始化文件路径 **/

    private Resource            r      = new ClassPathResource("fdfs_client.properties");

    /** 日志**/

    private final static Logger LOGGER = Logger.getLogger(FastdfsUtils.class);

    /**

     * 文件上传

     * @throws MyException 

     * @throws IOException 

     * @throws FileNotFoundException 

     */

    public MapString, String fileUpLoad(boolean isEmpty, InputStream inputStream, String fileName)

                                                                                                    throws Exception {

        MapString, String map = new HashMapString, String();

        if (isEmpty) {

            throw new Exception("");

        }

        ClientGlobal.init(r.getFile().getAbsolutePath());

        TrackerClient trackerClient = new TrackerClient();

        TrackerServer trackerServer = trackerClient.getConnection();

        StorageClient storageClient = new StorageClient(trackerServer, null);

        byte[] file_buff = null;

        if (inputStream != null) {

            file_buff = new byte[inputStream.available()];

            inputStream.read(file_buff);

        }

        String[] results = storageClient.upload_file(file_buff,

            FilenameUtils.getExtension(fileName), null);

        if (results == null) {

            throw new Exception("");

        }

        map.put("fileType", FilenameUtils.getExtension(fileName));

        map.put("original", fileName);

        map.put("url", results[0] + "/" + results[1]);

        map.put("state", "SUCCESS");

        map.put("groupName", results[0]);

        map.put("fileName", results[1]);

        return map;

    }

    /**

     * 文件下载

     */

    public byte[] fileDownLoad(String groupName, String fileName) throws IOException, MyException {

        ClientGlobal.init(r.getFile().getAbsolutePath());

        TrackerClient trackerClient = new TrackerClient();

        TrackerServer trackerServer = trackerClient.getConnection();

        StorageClient storageClient = new StorageClient(trackerServer, null);

        byte[] fileBytes = storageClient.download_file(groupName, fileName);

        return fileBytes;

    }

    /**

     * 文件删除

     */

    public void fileDelete(String groupName, String fileName) throws FileNotFoundException,

                                                             IOException, MyException {

        ClientGlobal.init(r.getFile().getAbsolutePath());

        TrackerClient trackerClient = new TrackerClient();

        TrackerServer trackerServer = trackerClient.getConnection();

        StorageClient storageClient = new StorageClient(trackerServer, null);

        storageClient.delete_file(groupName, fileName);

    }

}

关于fdfsjava和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。