Created
September 9, 2023 08:49
-
-
Save peterfei/e5b9b42c7f50dcdf7b275057f75c80bb to your computer and use it in GitHub Desktop.
又拍云本地上传云图片脚本
This file contains 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
-> % cat /usr/local/bin/upyun.sh | |
#!/bin/bash | |
# 云存储服务的名称 | |
bucket="xxx" | |
# 上传默认的路径 | |
file_path="/" | |
# 操作员 | |
operator="peterfei" | |
# 操作人密码 | |
operator_pwd="xxxx" | |
# 对象存储绑定的域名 | |
base_url="http://xxx.test.upcdn.net" | |
# i 就是Typora传的文件 | |
# Typora上传图片调用自定义命令时,会将待上传的图片作为命令行参数,传入脚本 | |
for i in "$@"; do | |
curl -T "$i" http://v0.api.upyun.com/"$bucket"/"$file_path" -u "$operator":"$operator_pwd" -v | |
done | |
# 输出结果 | |
echo "Upload Success:" | |
for file in "$@"; do | |
IFS='/' read -r -a array <<< "$file" | |
id="${#array[@]}" | |
echo "$base_url""$file_path""${array[$id-1]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment