This topic describes how to use ossutil to create a bucket, upload a local file to the bucket, download an object to the local computer, and generate a signed URL to share an object with third parties for downloads or previews.
Prerequisites
ossutil is installed. For more information, see Download and installation.
Usage notes
Each sample command line in this topic is based on the 64-bit Linux system. For other systems, replace ./ossutil64 of the command 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 corresponding 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 a bucket
- Command syntax
./ossutil64 mb oss://bucket
- Examples
You can run the following command to create a bucket named examplebucket:
./ossutil64 mb oss://examplebucket
If a similar result 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 an object named examplefile.txt to examplebucket:
./ossutil64 cp examplefile.txt oss://examplebucket
- You can upload an object named examplefile.txt to examplebucket and rename the object
exampleobject.txt.
./ossutil64 cp examplefile.txt oss://examplebucket/exampleobject.txt
If a similar result is displayed, the object is uploaded to the bucket.
0.720812(s) elapsed
- You can run the following command to upload an object named examplefile.txt to examplebucket:
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 rename the object exampleobject.txt:
./ossutil64 cp oss://examplebucket/examplefile.txt localfolder/exampleobject.txt
If a similar result 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 for an object
- 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 the following results are displayed, the signed URL is generated.
https://examplebucket.ss-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).