#!/usr/bin/env bash rm -f qshell wget http://devtools.qiniu.com/qshell-linux-x64-v2.4.2.zip unzip -o qshell-linux-x64-v2.4.2.zip mv qshell-linux-x64-v2.4.2 /tmp/qshell && chmod a+x /tmp/qshell && rm -f qshell-linux-x64-v2.4.2.zip FILENAME=$1 /tmp/qshell account $QN_AK $QN_SK 360cbs SIZE=$(ls -l | grep $FILENAME | awk '{print $5}') EXIT_CODE=0 if [[ $SIZE -lt '100000000' ]]; then echo "" echo "文件大小:$SIZE" echo "此文件小于100M,将采用表单上传" echo "" /tmp/qshell fput --overwrite $QN_BUCKET $2 $FILENAME | tee -a output.log RESULT=$(cat output.log | grep "Put" | awk -F ' ' '{print $NF}') echo $RESULT rm output.log if [[ $RESULT = 'success!' ]]; then echo "" echo "$2 上传成功!" echo "" else echo "Fail, please try again!" EXIT_CODE=255 fi elif [[ $SIZE -ge '100000000' ]]; then echo "" echo "文件大小:$SIZE" echo "此文件大于100M,将采用分片上传" echo "" /tmp/qshell rput --overwrite $QN_BUCKET $2 $FILENAME | tee -a output.log RESULT=$(cat output.log | grep "Put" | awk -F ' ' '{print $NF}') rm output.log if [[ $RESULT = 'success!' ]]; then echo "" echo "$2 上传成功!" echo "" else echo "Fail, please try again!" EXIT_CODE=255 fi else echo "Fail, please try again!" EXIT_CODE=255 fi exit $EXIT_CODE