Skip to content

Instantly share code, notes, and snippets.

@peterfei
Created September 9, 2023 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterfei/e5b9b42c7f50dcdf7b275057f75c80bb to your computer and use it in GitHub Desktop.
Save peterfei/e5b9b42c7f50dcdf7b275057f75c80bb to your computer and use it in GitHub Desktop.
又拍云本地上传云图片脚本
-> % 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