tianyunperfect 1 year ago
parent
commit
9cded64ffd
1 changed files with 13 additions and 6 deletions
  1. 13 6
      sh_config.sh

+ 13 - 6
sh_config.sh

@@ -327,16 +327,23 @@ memo() {
 function upload_file() {
 function upload_file() {
     file_path=$1
     file_path=$1
     if [ -z "$file_path" ]; then
     if [ -z "$file_path" ]; then
-        echo "Error: 请传入文件路径"
+        echo "Error: file_path is empty!"
         return 1
         return 1
     fi
     fi
     if [ ! -f "$file_path" ]; then
     if [ ! -f "$file_path" ]; then
-        echo "Error: 文件不存在"
+        echo "Error: file not exist!"
         return 1
         return 1
     fi
     fi
-    curl -k -X POST -F "file=@$file_path" https://web_history.tianyunperfect.cn/oss/upload_file
+    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")
     file_name=$(basename "$file_path")
     echo ''
     echo ''
-    echo "https://alist.tianyunperfect.cn/oss_gang/file/$file_name"
-    echo "https://tianyunperfect.oss-cn-hongkong.aliyuncs.com/file/$file_name"
-}
+    echo "https://alist.tianyunperfect.cn/oss_gang/$oss_path/$file_name"
+    echo "https://tianyunperfect.oss-cn-hongkong.aliyuncs.com/$oss_path/$file_name"
+}
+