minio_dw/old_upload_to_plugai.sh

41 lines
1019 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

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
# 用法提示
if [ $# -lt 1 ]; then
echo "❌ 用法: $0 <本地文件路径>"
exit 1
fi
# === 用户可配置部分 ===
file="$1"
bucket="plugai"
host="https://s3.szaiai.com" # 下载链接前缀
endpoint="https://api.szaiai.com" # MinIO 的 S3 API 访问地址
access_key="admin"
secret_key="Admin@123.."
alias="autoalias"
# === 检查文件是否存在 ===
if [ ! -f "$file" ]; then
echo "❌ 文件不存在: $file"
exit 1
fi
# === 设置 alias自动覆盖旧的 ===
mc alias rm $alias 2>/dev/null
mc alias set $alias $endpoint $access_key $secret_key > /dev/null
# === 确保目标 bucket 存在(如果不存在则创建) ===
mc mb --ignore-existing "$alias/$bucket" > /dev/null
# === 上传文件 ===
filename=$(basename "$file")
if mc cp "$file" "$alias/$bucket/$filename"; then
encoded=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$filename'''))")
echo "✅ 上传成功:$host/$bucket/$encoded"
else
echo "❌ 上传失败"
exit 1
fi