All Products
Search
Document Center

Object Storage Service:ossutil

Last Updated:Aug 30, 2023

This topic describes how to use ossutil to create a bucket and upload a local file to the bucket. After you upload a local file to the bucket, you can download the object stored in the bucket to your local computer or generate a signed URL to share the object with third parties for downloads or previews.

Video tutorial

The following video shows how to use ossutil.

Prerequisites

ossutil is installed. For more information, see Install ossutil.

Usage notes

The sample command lines in this topic are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For example, for the 64-bit Windows system, replace ./ossutil64 with ossutil64.exe. The following table lists the binary names that correspond to each system.

System

Binary name

64-bit Linux

./ossutil64

32-bit Linux

./ossutil32

64-bit Windows

ossutil64.exe

32-bit Windows

ossutil32.exe

64-bit macOS

./ossutilmac64

32-bit macOS

./ossutilmac32

64-bit ARM

./ossutilarm64

32-bit ARM

./ossutilarm32

Create buckets

  • Command syntax

    ./ossutil64 mb oss://bucket
  • Examples

    You can run the following command to create a bucket named examplebucket:

    ./ossutil64 mb oss://examplebucket

    If an output similar to the following one is displayed, the bucket named examplebucket is created.

    0.668238(s) elapsed

For more information about how to create buckets, see mb (create buckets).

Upload objects

  • Command syntax

    ./ossutil64 cp local_file oss://bucket
  • Examples

    • You can run the following command to upload a local file named examplefile.txt to examplebucket:

      ./ossutil64 cp examplefile.txt oss://examplebucket
    • You can run the following command to upload a local file named examplefile.txt to examplebucket and store the file as an object named exampleobject.txt:

      ./ossutil64 cp examplefile.txt oss://examplebucket/exampleobject.txt

    If an output similar to the following one is displayed, the file is uploaded to the bucket.

    0.720812(s) elapsed

For more information about how to upload objects, see Upload objects.

Download objects

  • Command syntax

    ./ossutil64 cp cloud_url local_file
  • Examples

    You can run the following command to download an object named examplefile.txt from examplebucket to a local directory named localfolder:

    ./ossutil64 cp oss://examplebucket/examplefile.txt localfolder/

    You can run the following command to download an object named examplefile.txt from examplebucket to a local directory named localfolder and store the object as a file named exampleobject.txt:

    ./ossutil64 cp oss://examplebucket/examplefile.txt localfolder/exampleobject.txt

    If an output similar to the following one is displayed, the object is downloaded to the specified local directory.

    0.720812(s) elapsed

For more information about how to download objects, see Download objects.

Generate a signed URL

  • Command syntax

    ./ossutil64 sign cloud_url [--timeout <value>]
  • Examples

    You can run the following command to generate a signed URL for the object oss://examplebucket/exampleobject.txt and set the validity period of the URL to 3,600 seconds:

    ./ossutil64 sign oss://examplebucket/exampleobject.txt --timeout 3600 

    If an output similar to the following one is displayed, the signed URL is generated.

    https://examplebucket.oss-cn-hangzhou.aliyuncs.com/exampleobject.txt?Expires=1608282224&OSSAccessKeyId=LTAI4G33piUmgRN1DXx9****&Signature=jo4%2FGykfuc1A4fvyvKRpRyymYH****
    0.368676(s) elapsed

For more information about how to generate signed URLs, see sign (generate signed object URLs).