标签:spec col 命令 tor track false stand 文件 font
# 安装tracker docker run -dti --network=host --name tracker -v /var/fdfs/tracker:/var/fdfs youkou1/fastdfs tracker # 安装storage docker run -dti --network=host --name storage -e TRACKER_SERVER=10.0.2.15:22122 -v /var/fdfs/storage:/var/fdfs youkou1/fastdfs storage
创建utils/fastdfs/client.conf配置文件
# connect timeout in seconds # default value is 30s connect_timeout=30 # network timeout in seconds # default value is 30s network_timeout=60 # the base path to store log files # base_path=utils/fastdfs/logs # tracker_server can ocur more than once, and tracker_server format is # "host:port", host can be hostname or ip address tracker_server=10.0.2.15:22122 #standard log level as syslog, case insensitive, value list: ### emerg for emergency ### alert ### crit for critical ### error ### warn for warning ### notice ### info ### debug log_level=info # if use connection pool # default value is false use_connection_pool = false # connections whose the idle time exceeds this time will be closed # unit: second # default value is 3600 connection_pool_max_idle_time = 3600 # if load FastDFS parameters from tracker server # default value is false load_fdfs_parameters_from_tracker=false # if use storage ID instead of IP address # same as tracker.conf # valid only when load_fdfs_parameters_from_tracker is false # default value is false use_storage_id = false # specify storage ids filename, can use relative or absolute path # same as tracker.conf # valid only when load_fdfs_parameters_from_tracker is false storage_ids_filename = storage_ids.conf #HTTP settings http.tracker_server_port=80
安装相关包
# 安装相关包 # fdfs_client.zip文件从百度云中下载 pip install fdfs_client.zip pip install mutagen pip install requests
# 通过 python manage.py shell 进入命令行, 在命令行中测试: >>> from fdfs_client.client import Fdfs_client >>> FDFS_Client = Fdfs_client(‘utils/fastdfs/client.conf‘) >>> ret = FDFS_Client.upload_by_filename(‘media/2018.png‘) getting connection <fdfs_client.connection.Connection object at 0x7f7f7f8e50b8> <fdfs_client.fdfs_protol.Tracker_header object at 0x7f7f7f8e5080> >>> ret {‘Group name‘: ‘group1‘, ‘Remote file_id‘: ‘group1/M00/00/00/CgACD1zWZtSAARmbAAfh_rrm7jw681.png‘, ‘Status‘: ‘Upload successed.‘, ‘Local file name‘: ‘media/2018.png‘, ‘Uploaded size‘: ‘504.00KB‘, ‘Storage IP‘: ‘10.0.2.15‘} >>> # 在浏览器中访问:http://127.0.0.1:8888/group1/M00/00/00/CgACD1zWZtSAARmbAAfh_rrm7jw681.png
views视图
FDFS_Client模块
标签:spec col 命令 tor track false stand 文件 font
原文地址:https://www.cnblogs.com/jun-1024/p/10958854.html