fileshare/curl_examples.sh
2025-08-10 12:57:17 +08:00

71 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# curl命令示例脚本 - 展示文件传输服务的基本用法
SERVER_URL="http://localhost:8000"
echo "📡 文件传输服务 - curl命令示例"
echo "================================="
echo
# 检查服务器是否运行
echo "🔍 检查服务器状态..."
if curl -s "$SERVER_URL/api" > /dev/null; then
echo "✅ 服务器运行正常"
else
echo "❌ 无法连接到服务器"
echo "💡 请先启动服务: python app.py"
exit 1
fi
echo
echo "🌐 Web界面: $SERVER_URL"
echo "📖 curl教程: $SERVER_URL/curl"
echo
# 显示使用示例
echo "📝 使用示例:"
echo
echo "1. 📤 上传文件:"
echo " curl -X POST -F \"file=@文件路径\" $SERVER_URL/api/upload"
echo
echo " 示例:"
echo " curl -X POST -F \"file=@photo.jpg\" $SERVER_URL/api/upload"
echo
echo "2. 📝 分享文本(超级简单):"
echo " curl -X POST --data \"你的文本\" $SERVER_URL/api/text"
echo
echo " 示例:"
echo " curl -X POST --data \"Hello World!\" $SERVER_URL/api/text"
echo
echo " 🔧 指定文件名:"
echo " curl -X POST -F \"content=Hello World!\" -F \"filename=hello.txt\" $SERVER_URL/api/share-text-form"
echo
echo "3. ⬇️ 下载文件:"
echo " curl -O -J $SERVER_URL/api/download/分享码"
echo
echo " 示例:"
echo " curl -O -J $SERVER_URL/api/download/AB12CD34"
echo
echo "4. 查看文件信息:"
echo " curl $SERVER_URL/api/info/分享码"
echo
echo " 示例:"
echo " curl $SERVER_URL/api/info/AB12CD34"
echo
echo "5. 📊 列出所有分享:"
echo " curl $SERVER_URL/api/shares"
echo
echo "================================="
echo "💡 提示:"
echo " - 无需安装任何额外工具"
echo " - 分享码为8位大写字母+数字"
echo " - 文件15分钟后自动过期"
echo " - 最大支持100MB文件"
echo
echo "📖 查看完整教程: $SERVER_URL/curl"