Browse Source

Merge remote-tracking branch 'origin/master'

tianyun 1 năm trước cách đây
mục cha
commit
dfc857fc70
1 tập tin đã thay đổi với 25 bổ sung1 xóa
  1. 25 1
      sh_config.sh

+ 25 - 1
sh_config.sh

@@ -326,4 +326,28 @@ memo() {
     else
         echo "失败" $response
     fi
-}
+}
+
+function upload_file() {
+    file_path=$1
+    if [ -z "$file_path" ]; then
+        echo "Error: file_path is empty!"
+        return 1
+    fi
+    if [ ! -f "$file_path" ]; then
+        echo "Error: file not exist!"
+        return 1
+    fi
+    oss_path=$2
+    # 如果没有传入oss路径,则
+    if [ -z "$oss_path" ]; then
+        oss_path="file"
+    fi
+    curl -k -X POST -F "file=@$file_path" -F "oss_path=$oss_path" https://web_history.tianyunperfect.cn/oss/upload_file
+
+    file_name=$(basename "$file_path")
+    echo ''
+    echo "https://alist.tianyunperfect.cn/oss_gang/$oss_path/$file_name"
+    echo "https://tianyunperfect.oss-cn-hongkong.aliyuncs.com/$oss_path/$file_name"
+}
+