FastDFS安装与使用

安装注意要修改:/etc/fdfs/client.confvim/etc/fdfs/client.网络
强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码

安装注意要修改:/etc/fdfs/client.conf

vim /etc/fdfs/client.conf
base_path=/home/yuqing/fastdfs 修改为: base_path=/home/fastdfs
tracker_server=192.168.209.121:22122 修改为: tracker_server=10.201.20.237:22122
##include http.conf  修改为: #include http.conf

 

启动tracker服务:
/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
启动storager服务:
/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
监控:
/usr/local/bin/fdfs_monitor /etc/fdfs/storage.conf
 
 
测试上传文件

用法:Usage: fdfs_test <config_file> upload <local_filename> [FILE | BUFF | CALLBACK]
测试:
cd /home/www/
fdfs_test /etc/fdfs/client.conf  upload  FlexPaper.zip

 

FastDFS调用

<?php
$tracker = fastdfs_tracker_get_connection();

if(!fastdfs_active_test($tracker))
{
        error_log("errno: " . fastdfs_get_last_error_no() . ", error info: " . fastdfs_get_last_error_info());
        exit(1);
}
$storage = fastdfs_tracker_query_storage_store();
if(!$storage)
{
        error_log("errno: " . fastdfs_get_last_error_no() . ", error info: " . fastdfs_get_last_error_info());
        exit(1);
}

$original_file1 = "/data/tools/85542.jpg";

$original_uploaded_info = fastdfs_storage_upload_by_filename($original_file1, null, array(), null, $tracker, $storage);

print_r($original_uploaded_info);
?>

返回:_Array=Array (    [group_name] => group2    [filename] => M00/00/00/ooYBAFIDdB6AZ18OAAAGJ5FjmEQ900.gif )

访问图片:http://192.168.0.115/group2/M00/00/00/ooYBAFIDdqiAbnVsAAF6R1oxgmg368.jpg

本文由来源 21aspnet,由 system_mush 整理编辑,其版权均为 21aspnet 所有,文章内容系作者个人观点,不代表 Java架构师必看 对观点赞同或支持。如需转载,请注明文章来源。

发表评论