minio_dw/ls_all_plugai_bucket_files.sh

23 lines
781 B
Bash
Raw Permalink 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
# === 用户可配置部分 ===
bucket="plugai"
host="https://s3.szaiai.com" # 生成的链接前缀
endpoint="https://api.szaiai.com" # MinIO 的 S3 API 访问地址
access_key="admin"
secret_key="Admin@123.."
alias="autoalias"
# === 设置 alias自动覆盖旧的 ===
mc alias rm $alias 2>/dev/null
mc alias set $alias $endpoint $access_key $secret_key > /dev/null
# === 列出文件并生成公开下载链接(自动 URL 编码) ===
mc ls --json --recursive "$alias/$bucket" | jq -r '.key' | while read file; do
encoded=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$file'''))")
echo "$host/$bucket/$encoded"
done
# list files size in bytes
mc ls --json szaiminio/plugai | jq -r '.key + " " + (.size|tostring) + " bytes"'