This topic describes how to obtain help information about ossutil commands.
Built-in help commands
To obtain help for any command, add -h or --help to the end of the command. To obtain help for a specific topic, use ossutil [topic]. The following table provides sample commands.
|
Description |
Command |
|
Displays help for available top-level commands in ossutil. |
|
|
Displays help for the cp command. |
|
|
Displays all subcommands under the api command. |
|
|
Displays help for the put-bucket-cors subcommand under the api command. |
|
|
Displays help for filter options. |
|
Command help format
Commands are divided into parent commands and subcommands. A parent command contains one or more subcommands, while a subcommand does not contain other commands.
Parent command help format
Help for a parent command includes five parts: description, usage, a list of subcommands, additional help topics, and other information.
ossutil is a command-line tool for managing data in Object Storage Service (OSS).
Usage: ossutil [command]
Available Commands:
api API-level commands
append Appends the content of a file to the end of an appendable object
cat Concatenates object content to standard output
config Creates a configuration file to store configuration items and access credentials
cp Uploads, downloads, or copies objects
du Gets the storage usage of a bucket or a specified prefix
hash Calculates the hash value of a file
help Help about any command
ls Lists buckets or objects
mb Creates a bucket
mkdir Creates an object whose name ends with a forward slash (/)
presign Generates a signed URL for an object
probe Probes commands
rb Deletes a bucket
restore Restores a frozen object to a readable state
revert Reverts a deleted object to the latest version
rm Deletes objects in a bucket
set-props Sets the properties of objects
stat Displays the description of a bucket or object
sync Synchronizes local directories or objects from a source to a destination
update Updates ossutil
version Displays version information
Additional help topics:
filter Provides details about filter parameters and how to use them in supported commands
Use "ossutil [command] --help" for more information about a command.
Use "ossutil [topic]" for more information about a topic.
Subcommand help format
Help for a subcommand includes six parts: a detailed description, usage, an optional alias, examples, local flags, and global flags.
Example 1: cat command
ossutil cat -h --language en
Outputs object content to standard output.
To run this command, you must have the oss:GetObject permission.
Usage: ossutil cat oss://bucket/object [flags]
Examples:
1) Output the content of the example.txt object in the examplebucket bucket to the screen
ossutil cat oss://examplebucket/example.txt
2) Output the content of the example.txt object with version ID CAEQARiBgID8rumR2h*** in the examplebucket bucket to the screen
ossutil cat oss://examplebucket/example.txt --version-id CAEQARiBgID8rumR2h***
3) Specify a range to output the content of the example.txt object in the examplebucket bucket to the screen
Display the first 10 characters
ossutil cat oss://examplebucket/example.txt --head 10
Display the last 10 characters
ossutil cat oss://examplebucket/example.txt --tail 10
From offset 10 to the end of the file
ossutil cat oss://examplebucket/example.txt --offset 10
20 characters starting from offset 10
ossutil cat oss://examplebucket/example.txt --offset 10 --count 20
Flags:
--count int Prints only N characters (default: -1)
--encoding-type string The encoding type of the input object name or file name. Valid value: "url"
--head int Prints only the first N characters
--offset int Starts printing from offset N
--request-payer string The payment method of the request. If the pay-by-requester mode is used, set this parameter. Valid value: "requester"
--tail int Prints only the last N characters
--version-id string The version ID of the object
Global Flags:
-i, --access-key-id string The AccessKey ID used to access OSS
-k, --access-key-secret string The AccessKey secret used to access OSS
--addressing-style string The format of the request endpoint (default: "virtual"). Valid values: "virtual", "path", and "cname"
-c, --config-file string The path of the configuration file (default: "~\\.ossutilconfig")
--connect-timeout int The client connection timeout period in seconds (default: 10)
-n, --dry-run Performs a trial run without making any changes
-e, --endpoint string The endpoint used to access OSS
-h, --help Displays help for the command
--language string The display language
--loglevel string The log level (default: "off"). Valid values: "off", "info", and "debug"
--mode string The authentication mode. Valid values: "AK", "StsToken", "EcsRamRole", and "Anonymous"
--output-format string The output format (default: "raw")
--output-properties strings The output parameter properties
--output-query string The JMESPath query condition
--profile string The specified profile in the configuration file
--read-timeout int The client read/write request timeout period in seconds (default: 20)
--region string The region where the data center is located
--retry-times int The number of retries when an error occurs (default: 10)
--sign-version string The signature algorithm version used for the request (default: "v4"). Valid values: "v1" and "v4"
--skip-verify-cert Specifies not to verify the server-side digital certificate
-t, --sts-token string The STS token used to access OSS
Example 2: put-bucket-cors command
ossutil api put-bucket-cors -h --language en
Sets cross-origin resource sharing (CORS) rules for a specified bucket.
- To call this operation, you must have the oss:PutBucketCors permission.
- CORS disabled by default
By default, CORS is disabled for a bucket. All cross-origin requests are denied.
- Overwrite semantics
PutBucketCors has overwrite semantics. A new CORS rule overwrites any existing CORS rules.
- Use CORS in applications
To use CORS in an application, you must manually upload a CORS rule using the PutBucketCors operation to enable CORS.
For example, to access OSS from example.com using the XMLHttpRequest feature of a browser, you must manually upload a CORS rule described in an XML document using this operation.
- CORS rule matching
When OSS receives a cross-origin request or an OPTIONS request, it reads the CORS rules of the bucket and performs permission checks. OSS checks each rule in sequence and uses the first matching rule to allow the request and return the corresponding headers. If no rules match, no CORS-related headers are returned.
A successful CORS rule match must meet the following three conditions:
- The request's Origin must match an AllowedOrigin item.
- The request method (such as GET or PUT) or the method specified in the Access-Control-Request-Method header of an OPTIONS request must match an AllowedMethod item.
- Each header included in the Access-Control-Request-Headers header of an OPTIONS request must match an AllowedHeader item.
For more information about the operation, see https://www.alibabacloud.com/help/en/oss/developer-reference/putbucketcors
Usage: ossutil api put-bucket-cors --bucket value --cors-configuration value [flags]
Examples:
The --cors-configuration option supports both XML and JSON syntax. If the option value starts with the file:// prefix, the configuration is read from the specified file.
XML Syntax:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>string</AllowedOrigin>
...
<AllowedMethod>string</AllowedMethod>
...
<AllowedHeader>string</AllowedHeader>
<ExposeHeader>string</ExposeHeader>
...
<MaxAgeSeconds>integer</MaxAgeSeconds>
</CORSRule>
...
<ResponseVary>boolean</ResponseVary>
</CORSConfiguration>
JSON Syntax:
{
"CORSRule": [
{
"AllowedOrigin": ["string", ...],
"AllowedMethod": ["string", ...],
"AllowedHeader": "string",
"ExposeHeader": ["string", ...],
"MaxAgeSeconds": integer
},
...
],
"ResponseVary": boolean
}
1) Allow cross-origin PUT and GET requests from www.aliyun.com, and set the cache time for the response to 10,000 seconds.
Use an XML configuration file. The following is the content of cors-configuration.xml:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>www.aliyun.com</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>10000</MaxAgeSeconds>
</CORSRule>
</CORSConfiguration>
ossutil api put-bucket-cors --bucket examplebucket --cors-configuration file://cors-configuration.xml
Use a JSON configuration file. The following is the content of cors-configuration.json:
{
"CORSRule": {
"AllowedOrigin": ["www.aliyun.com"],
"AllowedMethod": ["PUT","GET"],
"MaxAgeSeconds": 10000
}
}
ossutil api put-bucket-cors --bucket examplebucket --cors-configuration file://cors-configuration.json
Use JSON configuration parameters:
ossutil api put-bucket-cors --bucket examplebucket --cors-configuration "{\"CORSRule\":{\"AllowedOrigin\":[\"www.aliyun.com\"],\"AllowedMethod\":[\"PUT\",\"GET\"],\"MaxAgeSeconds\":10000}}"
Flags:
--bucket string The bucket name
--cors-configuration string The container for the CORS rules of the bucket
Global Flags:
-i, --access-key-id string The AccessKey ID used to access OSS
-k, --access-key-secret string The AccessKey secret used to access OSS
--addressing-style string The format of the request endpoint (default: "virtual"). Valid values: "virtual", "path", and "cname"
-c, --config-file string The path of the configuration file (default: "~\\.ossutilconfig")
--connect-timeout int The client connection timeout period in seconds (default: 10)
-n, --dry-run Performs a trial run without making any changes
-e, --endpoint string The endpoint used to access OSS
-h, --help Displays help for the command
--language string The display language
--loglevel string The log level (default: "off"). Valid values: "off", "info", and "debug"
--mode string The authentication mode. Valid values: "AK", "StsToken", "EcsRamRole", and "Anonymous"
--output-format string The output format (default: "raw")
--output-properties strings The output parameter properties
--output-query string The JMESPath query condition
--profile string The specified profile in the configuration file
--read-timeout int The client read/write request timeout period in seconds (default: 20)
--region string The region where the data center is located
--retry-times int The number of retries when an error occurs (default: 10)
--sign-version string The signature algorithm version used for the request (default: "v4"). Valid values: "v1" and "v4"
--skip-verify-cert Specifies not to verify the server-side digital certificate
-t, --sts-token string The STS token used to access OSS
The help for each subcommand includes the option type, option name, and description.
|
Option type |
Option name |
Description |
|
String |
--option string |
Example: --acl private |
|
Boolean |
--option |
Enables or disables an option. Example: --dry-run |
|
Integer |
--option Int |
An unsigned integer. Example: --read-timeout 10 |
|
Timestamp |
--option Time |
A timestamp in ISO 8601 format, which can be a DateTime or Date. Example: --max-mtime 2006-01-02T15:04:05 |
|
Byte unit suffix |
--option SizeSuffix |
The default unit is byte (B). You can also use unit suffixes. Supported suffixes are K (KiB) for 1,024 bytes, M (MiB), G (GiB), T (TiB), P (PiB), and E (EiB). Example: The minimum size is 1,024 bytes. --min-size 1024 --min-size 1K |
|
Time unit suffix |
--option Duration |
The time unit. The default unit is seconds (s). Supported unit suffixes include ms for milliseconds, s for seconds, m for minutes, h for hours, d for days, w for weeks, M for months, and y for years. Decimals are also supported. Example: 1.5 days --min-age 1.5d |
|
String list |
--option strings |
Supports single or multiple options with the same name. Supports multiple comma-separated values or a single value for each option. Example: --metadata user=jack, --metadata address=china |
|
String array |
--option stringArray |
Supports single or multiple options with the same name. Only a single value is supported for each option. Example: --include *.jpg --include *.txt |