Skip to content

Instantly share code, notes, and snippets.

@j796160836
Created May 10, 2024 07:20
Show Gist options
  • Save j796160836/56b5ea8a46cc8acfe5d9a44568c1b41b to your computer and use it in GitHub Desktop.
Save j796160836/56b5ea8a46cc8acfe5d9a44568c1b41b to your computer and use it in GitHub Desktop.
Upload file to Alist
#!/bin/bash
export HTTP_PROXY=http://192.168.1.3:3128
export HTTPS_PROXY=$HTTP_PROXY
export NO_PROXY="localhost, 127.0.0.1"
domain='https://YOUR_SERVER_IP'
token='xxxxxxxxxx'
file=$1
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"
unset HTTP_PROXY
unset HTTPS_PROXY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment