Ossutil allows you to upload/download/copy a file, set the ACL and meta of an object, and view the meta information of an object.

Run the config command to configure the AccessKey pair before running these commands.

  • Upload/Download/Copy a file

    You are strongly advised to use ossutil help cp to view the help information before running the cp command.

    When running the cp command to upload/download/copy a file, use the -r option to copy a folder. Ossutil implements multipart upload by default for large files and supports resumable data transfers (the threshold of large files for which multipart upload is enabled can be set using the --bigfile-threshold option.)

    Use the -f option to forcibly upload a file by default. If a file exists with the same name on the target end, the file is overwritten directly.

    If an error occurs to a file during file uploading/downloading/copying in batches, ossutil logs the error information in the report file by default, skips this file, and performs operations on other files. For more information, see ossutil help cp.

    Note Ossutil does not continue to copy other files if the bucket does not exist, or if the permission verification result is invalid due to an incorrect AccessKeyID or AccessKeySecret.

    Ossutil supports the incremental uploading policies --update and --snapshot-path in specific scenarios. For more information, see ossutil help cp.

    From ossutil 1.0.0. Beta1, crc64 is enabled by default during file uploading.

    • Upload a single file:
      $./ossutil cp a oss://ossutil-test
      Succeed: Total num: 1, size: 230. OK num: 1(upload 1 files).
      0.699795(s) elapsed
    • Upload a folder:
      $./ossutil cp -r dir oss://ossutil-test
      Succeed: Total num: 35, size: 464,606. OK num: 35(upload 34 files, 1 directories).
      0.896320(s) elapsed
  • Modify the storage class of an object
    Notice To modify the storage class of an object that is less than or equal to 5 GB, run the set-meta command. To modify the storage class of an object that is greater than 5 GB, run the cp command.
    • You can run the set-meta command to modify the storage class of an object.
      • Run the following command to set the storage class of a single object to IA:
        ./ossutil set-meta oss://hello-hangzws/0104_6.jpg X-Oss-Storage-Class:IA -u
      • Run the following command to set the storage class of all objects in a folder to Standard:
        ./ossutil set-meta oss://hello-hangzws/abc/ X-Oss-Storage-Class:Standard -r -u
    • You can run the cp command to upload an object while using the --meta option to modify the storage class of the object.
      • Run the following command to upload a single file and set the storage class of the file to IA:
        ossutil cp ~/Downloads/sys.log  oss://hello-hangzws/test/ --meta X-oss-Storage-Class:IA
      • Run the following command to upload a folder and set the storage class of all files in the folder to IA:
        ./ossutil cp ~/libs3/ oss://hello-hangzws/test/ --meta X-oss-Storage-Class:IA -r
      • Run the following command to modify the storage class of an existing object to Archive:
        ./ossutil cp oss://hello-hangzws/0104_6.jpg oss://hello-hangzws/0104_6.jpg --meta X-oss-Storage-Class:Archive
      • Run the following command to modify the storage class of all objects in an existing folder to Standard:
        ./ossutil cp oss://hello-hangzws/test/ oss://hello-hangzws/test/ --meta X-oss-Storage-Class:Standard -r
      Notice
      • The storage class of an object cannot be changed from Archive to other classes by running the set-meta or . You must run the restore command first to change the storage class of the object to IA, and then run the set-meta or cp command to change the storage class of the object to other classes.
      • An object is considered as overwritten and may be charged when you run the cp command to overwrite the object. An object of the IA or Archive class will be charged if it is overwritten within 30 and 60 days separately after it is created. For example, if you change the storage class of an object from IA to Archive or Standard by running the cp command 10 days after the object is created, early deletion fees for 20 days will be charged.
  • Performance tuning for uploading, downloading, or copying a file
    In the cp command, the --jobs and --parallel options are used to control the number of concurrent operations. If the default number of concurrent operations set by ossutil cannot meet the performance requirement, you can modify the values of the two options to adjust the performance.
    • The --jobs option controls the number of concurrent operations enabled among files when multiple files are uploaded, downloaded, or copied.
    • The--parallel option controls the number of concurrent operations enabled for a large file when the large file is uploaded/downloaded/copied in the multipart method.

    By default, ossutil calculates the number of concurrent operations based on the file size (this option does not work for small files, and the threshold for large files to be uploaded/downloaded/copied in the multipart method can be controlled by the --bigfile-threshold option). When large files are uploaded/downloaded/copied in batches, the actual number of concurrent operations is calculated by multiplying the number of jobs by the number of parallel operations.

    Warning
    • We recommend that you adjust the number of concurrent operations to a value smaller than 100 if the resources of your ECS instance or server (such as network bandwidth, memory, and CPU) are limited. If the resources are not fully occupied, you can try to set the concurrent operations to a larger value.
    • If there are too many concurrent operations, the uploading, downloading, and copying performance of ossutil may degrade, or an EOF error may occur due to inter-thread resource switching and snatching. To resolve this issue, you must adjust the values of --jobs and --parallel based on the actual conditions. To perform pressure testing, set the two options to small values first, and slowly adjust them to the optimal values.
  • Configure the ACL of an object

    Ossutil uses the set-acl command to configure the ACL of an object. You can use the -r option to configure the ACLs of objects in batches.

    For more information, see ossutil help set-acl.

    $./ossutil set-acl oss://dest/a private
    0.074507(s) elapsed

    Configure the ACLs of objects in batches:

    $./ossutil set-acl oss://dest/a private -r
    Do you really mean to recursivlly set acl on objects of oss://dest/a(y or N)? y
    Succeed: Total 3 objects. Setted acl on 3 objects.
    0.963934(s) elapsed
  • Configure the meta of an object

    Ossutil uses the set-meta command to configure the meta information of an object. You can use the -r option to configure the metas of objects in batches.

    For more information, see ossutil help set-meta.

    ./ossutil set-meta oss://dest/a x-oss-object-acl:private -u
  • View the object description (meta)

    Ossutil uses the stat command to view the object description (meta).

    For more information, see ossutil help stat.

    $./ossutil stat oss://dest/a 
    ACL                         : default
    Accept-Ranges               : bytes
    Content-Length              : 230
    Content-Md5                 : +5vbQC/MSQK0xXSiyKBZog==
    Content-Type                : application/octet-stream
    Etag                        : FB9BDB402FCC4902B4C574A2C8A059A2
    Last-Modified               : 2017-01-13 15:14:22 +0800 CST
    Owner                       : aliyun
    X-Oss-Hash-Crc64ecma        : 12488808046134286088
    X-Oss-Object-Type           : Normal
    0.125417(s) elapsed
  • Restore an object from the frozen state to the readable state

    Ossutil uses the restore command to restore an object from the frozen state to the readable state. You can use the -r option to restore objects from the frozen state to the readable state in batches.

    For more information, see ossutil help restore.

    $./ossutil restore oss://utiltest/a
    0.037729(s) elapsed
  • Create a symbolic link

    Ossutil uses the create-symlink command to create a symbolic link.

    For more information, see ossutil help create-symlink.

    $./ossutil create-symlink oss://utiltest/b a
    0.037729(s) elapsed
  • Read the description of a symbolic link file

    Ossutil uses the read-symlink command to read the description of a symbolic link file.

    For more information, see ossutil help read-symlink.

    $./ossutil read-symlink oss://utiltest/b
    Etag                    : D7257B62AA6A26D66686391037B7D61A
    Last-Modified           : 2017-04-26 15:34:27 +0800 CST
    X-Oss-Symlink-Target    : a
    0.112494(s) elapsed