1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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