注意1:需要将 qshell 加入环境变量
mv qshell /usr/local/bin/qshell
http://developer.qiniu.com/code/v6/tool/qshell.html
注意2:此脚本需要注册七牛云账号,获取 ak 和 sk,以及创建 bucket 用于存储
快速入门:
http://developer.qiniu.com/article/kodo/kodo-first/quickstart.html
需要配置的参数
- ak sk
- bucket
- domain
shell 脚本如下:
#!/usr/bin/env bash
ii=$1
qshell account <ak> <sk>
jj=$(ls -l | grep $ii | awk '{print $5}')
if [[ $jj -lt '100000000' ]];
then
echo ""
echo "文件大小:$bb"
echo "此文件小于100M,将采用表单上传"
echo ""
qshell fput <bucket> $ii $1 | tee -a test1111
xx=$(cat test1111 | grep "Put" | awk -F ')' '{print $2}')
rm test1111
if [[ $xx = ' success!' ]];
then
echo ""
echo "访问链接:"
echo "http://<domain>/$ii"
echo ""
else
echo "Fail, please try again!"
fi
elif [[ $jj -ge '100000000' ]];
then
echo ""
echo "文件大小:$bb"
echo "此文件大于100M,将采用分片上传"
echo ""
qshell rput <bucket> $ii $1 | tee -a test1111
xx=$(cat test1111 | grep "Put" | awk -F ')' '{print $2}')
rm test1111
if [[ $xx = ' success!' ]];
then
echo ""
echo "访问链接:"
echo "http://<domain>/$ii"
echo ""
else
echo "Fail, please try again!"
fi
else
echo "File error~ 卧槽日了狗"
fi