|
|
|
@ -29,6 +29,7 @@ AccessKeySecret=`cat $config_file | jq -r .aliyun_oss.AccessKeySecret` |
|
|
|
|
db_file=`cat $config_file | jq -r .aliyun_oss.db` |
|
|
|
|
db_file_err=$db_file.err |
|
|
|
|
imageParam=`cat $config_file | jq -r .aliyun_oss.imageParam` |
|
|
|
|
deleteApi=`cat $config_file | jq -r .aliyun_oss.deleteApi` |
|
|
|
|
|
|
|
|
|
convertio_apikey=`cat $config_file | jq -r .convertio.apikey` |
|
|
|
|
|
|
|
|
@ -41,12 +42,10 @@ then |
|
|
|
|
touch $db_file |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
function upload(){ |
|
|
|
|
function PutObject(){ |
|
|
|
|
VERB="PUT" |
|
|
|
|
file=$1 |
|
|
|
|
Content_MD5="" |
|
|
|
|
Content_Type="application/x-www-form-urlencoded" |
|
|
|
|
Content_Type="text/plain" |
|
|
|
|
Content_Type=`file -b --mime-type $file` |
|
|
|
|
Date=`TZ=GMT env LANG=en_US.UTF-8 date +'%a, %d %b %Y %H:%M:%S GMT'` |
|
|
|
|
CanonicalizedOSSHeaders="x-oss-object-acl:public-read\n" |
|
|
|
@ -54,7 +53,7 @@ function upload(){ |
|
|
|
|
stringToSign="$VERB\n$Content_MD5\n$Content_Type\n$Date\n$CanonicalizedOSSHeaders$CanonicalizedResource" |
|
|
|
|
Signature=`echo -en $stringToSign | openssl sha1 -hmac $AccessKeySecret -binary | base64` |
|
|
|
|
Authorization="OSS $AccessKeyId:$Signature" |
|
|
|
|
http_code=`curl -v -w "%{http_code}" -X PUT -H "HOST:$bucketname.$Host" -H "x-oss-object-acl:public-read" -H "Date:$Date" -H "Content-Type:$Content_Type" -H "Authorization:$Authorization" --data-binary "@$file" "https://$bucketname.$Host/$file"` |
|
|
|
|
http_code=`curl -v -w "%{http_code}" -X $VERB -H "HOST:$bucketname.$Host" -H "x-oss-object-acl:public-read" -H "Date:$Date" -H "Content-Type:$Content_Type" -H "Authorization:$Authorization" --data-binary "@$file" "https://$bucketname.$Host/$file"` |
|
|
|
|
if [ $http_code -eq "200" ] |
|
|
|
|
then |
|
|
|
|
echo $file>>$db_file |
|
|
|
@ -64,6 +63,30 @@ function upload(){ |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function DeleteMultipleObjects(){ |
|
|
|
|
temp_file=DeleteMultipleObjects.json |
|
|
|
|
while true |
|
|
|
|
do |
|
|
|
|
curl -v -d "AccessKeyId=$AccessKeyId&AccessKeySecret=$AccessKeySecret&host=$Host&bucketname=$bucketname&max=50" $deleteApi > $temp_file |
|
|
|
|
cat $temp_file |
|
|
|
|
count=`cat $temp_file|jq -r .count` |
|
|
|
|
echo "剩余需要清理文件个数:$count" |
|
|
|
|
if [ $count == 0 ] |
|
|
|
|
then |
|
|
|
|
echo "delete finish" |
|
|
|
|
break |
|
|
|
|
fi |
|
|
|
|
for item in `cat $temp_file|jq -r ".delete_files[]"` |
|
|
|
|
do |
|
|
|
|
sed -i "/$item/g" $db_file |
|
|
|
|
done |
|
|
|
|
sed -i "/^\s*$/d" $db_file |
|
|
|
|
sleep 1m |
|
|
|
|
done |
|
|
|
|
rm -f $temp_file |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fileSizeStr(){ |
|
|
|
|
fileSize=$1 |
|
|
|
|
if [[ $fileSize -gt 1048576 ]] |
|
|
|
@ -224,7 +247,7 @@ do |
|
|
|
|
if [[ `echo $result|jq -r .status` = ok && `echo $result|jq -r .data.step` = finish ]] |
|
|
|
|
then |
|
|
|
|
echo $result|jq .data.output.url|xargs curl -v -o $original_file_name |
|
|
|
|
upload $original_file_name |
|
|
|
|
PutObject $original_file_name |
|
|
|
|
break |
|
|
|
|
elif [ `echo $result|jq -r .status` = error ] |
|
|
|
|
then |
|
|
|
@ -240,7 +263,7 @@ do |
|
|
|
|
echo "Start a New Conversion error!!!" |
|
|
|
|
fi |
|
|
|
|
else |
|
|
|
|
upload $original_file_name |
|
|
|
|
PutObject $original_file_name |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
fi |
|
|
|
@ -297,3 +320,4 @@ curl -v -d chat_id=$chat_id -d text="以上就是$today日榜前${length}名作 |
|
|
|
|
find -type f -mtime +7|grep html |
|
|
|
|
find -type f -mtime +7|grep json |
|
|
|
|
find -type f -mtime +7|grep webp |
|
|
|
|
DeleteMultipleObjects |