Seven niuyun link failure, god vexed, later submitted work order, reply to the solution, but dislike trouble, pondering. I wrote a script to download to the local, and then upload to Ali cloud with the command. Only available for MAC….

7 niuyun failed link on the file, download to the local

  • Download QRSCTL first and copy the path of this file locally
  • Modify the permissions on this fileChmod + x/Users/ZHM/Downloads/qshell - v2.3.6 / QRSCTL, pay attention to the path here
  • Log on to Seven Niuyun/ Users/ZHM/Downloads/qshell v2.3.6 / QRSCTL login password
  • The new fileqiniuyun_down.shCopy the following, configure the first two paths, and execute the scriptsh qiniuyun_down.shThat’s it!
#! /bin/bash
# !!!!! Here you must configure the QRSCTL path and which folder you want to save to
# suppose you have two buckets for Foods Balls and the local folder you want to save is /Users/xx
# After executing this script, /Users/xx automatically generates two folders foods and balls, which contain the corresponding files

# Your own QRSCT installation path
qrsctlPath='/ Users/ZHM/Downloads/qshell - v2.3.6 / QRSCTL'
Which folder do you want your pictures to be placed under
saveDirectory='/Users/zhm/Pictures/blog'

Download all the files in a bucket
downBucketFiles(){
    bucket=The $1
    echo "$bucket"
    filenamePath="${saveDirectory}/${bucket}.txt"
    # filenamePath=$saveDirectory/$bucket.txt
    Put all the file names of a bucket into the local file filenamePath
    $qrsctlPath listprefix $bucket "" > $filenamePath
    # here I want bucke as a subdirectory, so if I don't use it, I don't need to write this
    # saveDirectory=$saveDirectory/$bucket
    saveBucketDirectory="${saveDirectory}/${bucket}"
    mkdir $saveBucketDirectory
    TODO does not optimize == for the first line
    i=1
    Get all the file names and loop the download
    for line in $(cat $filenamePath)
    do 
        if [ $i -gt1]then
        filename=$line
        localFilePath="${saveBucketDirectory}/${filename}"
        # download
        $qrsctlPath get $bucket $filename $localFilePath
        fi
        i=$(($i+ 1))done
    # delete the created TXT
    rm $filenamePath
}

Download the files inside each bucket
execDownload() {[room IMgs Library baby]
    buckets=$($qrsctlPath buckets)
    strLength=${#buckets}
    # room imgs library baby
    buckets=${buckets:1:$strLength-2}
    echo "$buckets"
    # Looping each bucket TODO can obviously be optimized
    #!!!!!!!!!! A particularly strange point, where j can not be replaced by I, may be related to scope, step on a deep pit, a long time to find the bug
    j=1
    while((1 = = 1))do
        bucket=`echo $buckets|cut -d "" -f$j`
        if [ "$bucket"! ="" ]
        then
            ((j++))
            echo "-- -- -- -- --$bucket start download-----"

            downBucketFiles $bucket;
            echo "-- -- -- -- --$bucket finish download-----"
        else
            break
        fi
    done

}
echo "----- function begins to execute -----"
execDownload
echo "----- function completed -----"
Copy the code

Upload to Aliyun

The following logically can also write into the script, did not write, according to the official website to see the next, you need to configure.

cd~ the curl - o ossutilmac64 http://gosspublic.alicdn.com/ossutil/1.6.0/ossutilmac64 chmod 755 ossutilmac64. / ossutilmac64 configThis command creates a configuration file in which to store the configuration information. Please enter the configuration file path (the default is: / home/user /. Ossutilconfig, enter the default path will be used. If the user has set the --config-file option to a different path when using the command) :
# did not enter a configuration file path, will use the default configuration file: / home/user /. Ossutilconfig.
For the following configuration, press Enter to skip the configuration items. For details about the configuration items, run the "help config" command.
Enter endpoint: http://oss-cn-shenzhen.aliyuncs.com
Please enter accessKeyID: yourAccessKeyID
# please enter accessKeySecret: yourAccessKeySecret uOPouBlhXpI9J2KSgB9ra5tUCQEcHn
# Please enter stsToken: I don't have this

Create a directory
./ossutilmac64 mkdir oss://blog-huahua/
# upload folder
./ossutilmac64 cp -r /Users/zhm/Pictures/blog oss://blog-huahua/blog/
Copy the code

disadvantages

  • Only for MAC
  • No error message was caught
  • In fact, the previous steps can also be written into the script but not ha ha ha

The introduction of ossutilmac64