ossutil is a command-line tool that you can use to efficiently manage objects in Object Storage Service (OSS). For example, you can use ossutil to upload large objects, download objects, and share objects. To upload objects to OSS, you must first create a bucket. After you upload objects, you can download the objects to your local device or share the objects with other users for downloads or previews by using signed URLs.
Prerequisites
ossutil is installed. For more information, see Install ossutil.
OSS is activated. For more information, see Activate OSS.
Create a bucket
Command syntax
ossutil mb oss://bucket
Examples
You can run the following command to create a bucket named examplebucket:
ossutil mb oss://examplebucket
If the output is similar to the following content, the bucket is created.
0.668238(s) elapsed
For more information about how to create a bucket, see mb (create buckets).
Upload an object
Command syntax
ossutil cp local_file oss://bucket
Examples
You can run the following command to upload a local file named examplefile.txt to examplebucket:
ossutil 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:
ossutil cp examplefile.txt oss://examplebucket/exampleobject.txt
If the output is similar to the following content, the file is uploaded to the bucket.
0.720812(s) elapsed
For more information about how to upload objects, see Upload objects.
Download an object
Command syntax
ossutil 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:
ossutil 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:
ossutil cp oss://examplebucket/examplefile.txt localfolder/exampleobject.txt
If the output is similar to the following content, 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
ossutil sign cloud_url [--timeout <value>]
Examples
You can run the following command to generate a signed URL for the
oss://examplebucket/exampleobject.txt
object and set the validity period of the URL to 3,600 seconds:ossutil sign oss://examplebucket/exampleobject.txt --timeout 3600
If the output is similar to the following content, 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 a signed URL, see sign (generate signed object URLs).