Este tópico descreve como obter informações de ajuda sobre os comandos do ossutil.
Comandos de ajuda integrados
Para obter ajuda sobre qualquer comando, adicione -h ou --help ao final dele. Caso precise de informações sobre um tópico específico, use ossutil [topic]. A tabela a seguir apresenta exemplos de comandos.
|
Descrição |
Comando |
|
Mostra a ajuda dos comandos de nível superior disponíveis no ossutil. |
|
|
Apresenta a ajuda referente ao comando cp. |
|
|
Lista todos os subcomandos do comando api. |
|
|
Exibe a ajuda do subcomando put-bucket-cors, pertencente ao comando api. |
|
|
Fornece ajuda sobre as opções de filtro. |
|
Formato da ajuda de comandos
Os comandos se dividem em comandos pai e subcomandos. Um comando pai contém um ou mais subcomandos, enquanto um subcomando não contém outros comandos.
Formato da ajuda de comandos pai
A ajuda de um comando pai inclui cinco partes: descrição, uso, lista de subcomandos, tópicos de ajuda adicionais e outras informações.
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.
Formato da ajuda de subcomandos
A ajuda de um subcomando inclui seis partes: descrição detalhada, uso, alias opcional, exemplos, flags locais e flags globais.
Exemplo 1: comando cat
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
Exemplo 2: comando put-bucket-cors
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
A ajuda de cada subcomando inclui o tipo de opção, o nome da opção e a descrição.
|
Tipo de opção |
Nome da opção |
Descrição |
|
String |
--option string |
Exemplo: --acl private |
|
Boolean |
--option |
Ativa ou desativa uma opção. Exemplo: --dry-run |
|
Integer |
--option Int |
Um inteiro sem sinal. Exemplo: --read-timeout 10 |
|
Timestamp |
--option Time |
Um carimbo de data e hora no formato ISO 8601, que pode ser DateTime ou Date. Exemplo: --max-mtime 2006-01-02T15:04:05 |
|
Sufixo de unidade de byte |
--option SizeSuffix |
A unidade padrão é o byte (B). Você também pode usar sufixos de unidade. Os sufixos suportados são K (KiB) para 1.024 bytes, M (MiB), G (GiB), T (TiB), P (PiB) e E (EiB). Exemplo: O tamanho mínimo é de 1.024 bytes. --min-size 1024 --min-size 1K |
|
Sufixo de unidade de tempo |
--option Duration |
A unidade de tempo. A unidade padrão é o segundo (s). Os sufixos de unidade suportados incluem ms para milissegundos, s para segundos, m para minutos, h para horas, d para dias, w para semanas, M para meses e y para anos. Valores decimais também são suportados. Exemplo: 1,5 dias --min-age 1.5d |
|
Lista de strings |
--option strings |
Aceita uma ou mais opções com o mesmo nome, permitindo múltiplos valores separados por vírgula ou um único valor para cada opção. Exemplo: --metadata user=jack, --metadata address=china |
|
Array de strings |
--option stringArray |
Aceita uma ou várias opções com o mesmo nome. Permite apenas um único valor para cada opção. Exemplo: --include .jpg --include .txt |