Last active
August 20, 2025 09:51
-
-
Save j796160836/56b5ea8a46cc8acfe5d9a44568c1b41b to your computer and use it in GitHub Desktop.
Upload file to Alist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TODO: 如果有需要,修改 Proxy 設定 | |
export HTTP_PROXY=http://192.168.1.3:3128 | |
export HTTPS_PROXY=$HTTP_PROXY | |
export NO_PROXY="localhost, 127.0.0.1" | |
# TODO: 修改 Server 路徑與 Token | |
domain='https://YOUR_SERVER_IP' | |
token='xxxxxxxxxx' | |
file=$1 | |
# TODO: 如果有需要,修改檔案上傳路徑,注意同名檔案會自動被覆蓋 | |
remotePath="/uploads/$(date +"%Y-%m-%d")/$file" | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: ./upload.sh file.txt" | |
exit 1 | |
fi | |
if [ ! -f "$1" ]; then | |
echo "$1 file not found!" | |
exit 1 | |
fi | |
curl -X PUT "$domain/api/fs/put" -H "Authorization:$token" -H "File-Path:$remotePath" -T "$file" | |
# TODO: 如果有需要,修改 Proxy 設定 | |
unset HTTP_PROXY | |
unset HTTPS_PROXY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment