全部产品
Search
文档中心

对象存储 OSS:命令行选项

更新时间:Sep 09, 2024

命令行选项的优先级最高,可以覆盖配置文件设置或环境变量设置的参数。命令行选项分为全局命令行选项和局部命令行选项。全局命令行选项适用于所有命令,局部命令行选项仅适用于特定的命令。

查询命令行选项

执行以下命令查询命令行选项:

ossutil cp -h

输出内容如下:

Flags:
      --acl string                         The access control list (ACL) of the object, valid value(s): "private","public-read","public-read-write","default"
      --bandwidth-limit SizeSuffix         Bandwidth limit in B/s, or use suffix B|K|M|G|T|P
      --bigfile-threshold SizeSuffix       The threshold of file size, the file size larger than the threshold will use multipart upload, download or copy, or use suffix B|K|M|G|T|P (default 100Mi)
      --cache-control string               The caching behavior of the web page when the object is downloaded
      --checkers int                       Number of checkers to run in parallel (default 16)
      --checkpoint-dir string              The specified directory for breakpoint continuation information
      --checksum                           Only copy the source file with different size and checksum(if available)
      --content-disposition string         The method that is used to access the object
      --content-encoding string            The method that is used to encode the object
      --content-type string                The mime type of object
      --copy-props string                  Determines which properties are copied from the source object, valid value(s): "none","metadata","default"
  -d, --dirs                               Return matching subdirectory names instead of contents of the subdirectory
      --encoding-type string               The encoding type of object name or file name that user inputs, valid value(s): "url"
      --end-with string                    The name of the object from which the list operation ends, include
      --exclude stringArray                Exclude files matching pattern
      --exclude-from stringArray           Read exclude patterns from file
      --expires string                     The expiration time of the cache in UTC
      --files-from stringArray             Read list of source-file names from file, ignores blank and comment line
      --files-from-raw stringArray         Read list of source-file names from file without any processing of lines
      --filter stringArray                 A file-filtering rule
      --filter-from stringArray            Read file filtering rules from a file
  -f, --force                              Operate silently without asking user to confirm the operation
      --include stringArray                Don't exclude files matching pattern
      --include-from stringArray           Read include patterns from file
  -j, --job int                            Amount of concurrency tasks between multi-files (default 3)
      --list-objects                       Use ListObjects instead of ListObjectsV2 to list objects
      --max-age Duration                   Don't transfer any file older than this, in s or suffix ms|s|m|h|d|w|M|y (default off)
      --max-mtime Time                     Don't transfer any file younger than this, UTC time format (default off)
      --max-size SizeSuffix                Don't transfer any file larger than size, in B or suffix B|K|M|G|T|P, 1K(KiB)=1024B
      --metadata strings                   Specifies the object's user metadata, in key=value foramt
      --metadata-directive string          The method that is used to configure the metadata of the destination object, valid value(s): "COPY","REPLACE"
      --metadata-exclude stringArray       Exclude metadata matching pattern
      --metadata-filter stringArray        A metadata-filtering rule
      --metadata-filter-from stringArray   Read metadata filtering rules from a file
      --metadata-include stringArray       Don't exclude metadata matching pattern
      --min-age Duration                   Don't transfer any file younger than this, in s or suffix ms|s|m|h|d|w|M|y (default off)
      --min-mtime Time                     Don't transfer any file older than this, UTC time format (default off)
      --min-size SizeSuffix                Don't transfer any file smaller than size, in B or suffix B|K|M|G|T|P, 1K(KiB)=1024B
      --no-error-report                    Don't generate error report file during batch operation
      --no-progress                        The progress is not displayed
      --output-dir string                  Specifies the directory to place output file in, output file contains: error report file generated during batch operation (default "ossutil_output")
      --page-size int                      The number of results to return in each response to a list operation (default 1000), in the range 1 - 1000
      --parallel int                       Amount of concurrency tasks when work with a file
      --part-size SizeSuffix               The part size, calculated the suitable size according to file size by default, or use suffix B|K|M|G|T|P, in the range 100Ki - 5Gi
  -r, --recursive                          Operate recursively, if the option is specified, the command will operate on all match objects under the bucket, else operate on the single object.
      --request-payer string               The payer of the request. set this value if you want pay for requester, valid value(s): "requester"
      --size-only                          Only copy the source file with different size
      --start-after string                 The name of the object from which the list operation starts, not include
      --storage-class string               The storage class of the object, valid value(s): "Standard","IA","Archive","ColdArchive","DeepColdArchive"
      --tagging strings                    Specifies the tag of the destination object, in key=value foramt
      --tagging-directive string           The method that is used to configure tags for the destination object, valid value(s): "COPY","REPLACE"
  -u, --update                             Only copy when the source file is newer than the destination file

Global Flags:
  -i, --access-key-id string        AccessKeyID while access oss
  -k, --access-key-secret string    AccessKeySecret while access oss
      --addressing-style string     The style in which to address endpoints (default "virtual"), valid value(s): "virtual","path","cname"
  -c, --config-file string          The path of the configuration file (default "~/.ossutilconfig")
      --connect-timeout int         The client connection timed out, the unit is: s (default 10)
  -n, --dry-run                     Do a trial run with no permanent changes
  -e, --endpoint string             The domain names that other services can use to access OSS.
  -h, --help                        help for the command
      --language string             The display text language
      --log-file string             Specifies the log output file. When -, outputs to Stdout
      --loglevel string             The debug message level (default "off"), valid value(s): "off","info","debug"
      --mode string                 Specifies the authentication mode, valid value(s): "AK","StsToken","EcsRamRole","Anonymous"
      --output-format string        The formatting style for command output (default "raw")
      --output-properties strings   The properties of output format
      --output-query string         A JMESPath query to use in filtering the response data
      --profile string              Specific profile from your config file.
      --proxy string                Specifies the proxy server. When 'env', use HTTP_PROXY and HTTPS_PROXY environment variables
  -q, --quiet                       Quiet mode, print as little stuff as possible
      --read-timeout int            The client read timed out, the unit is: s (default 20)
      --region string               The region in which the bucket is located.
      --retry-times int             Retry times when fail (default 10)
      --role-arn string             Specifies the ARN of role
      --role-session-name string    Specifies the session name
      --sign-version string         The version of the signature algorithm (default "v4"), valid value(s): "v1","v4"
      --skip-verify-cert            Specifies that the oss server's digital certificate file will not be verified
  -t, --sts-token string            STSToken while access oss

使用命令行选项

在命令行操作中,部分命令需要附加参数以指定操作对象或设置选项,而其他命令则不需要参数。对于带参数的命令,您可以根据具体要求提供适当的参数值,以实现预期的功能,例如,带参数的命令如:

ossutil ls --profile dev

ossutil ls --profile dev允许用户通过参数值dev指定特定的配置文件。带参数的选项通常需要通过空格或等号(=)将选项名称与参数值分隔,例如--profile dev--profile=dev。当参数值包含空格时,必须使用双引号将整个参数值括起来,以确保命令正确解析,例如 --description "OSS bucket list"

支持的全局命令行选项

参数

类型

说明

-i, --access-key-id

string

访问OSS使用的AccessKey ID。

-k, --access-key-secret

string

访问OSS使用的AccessKey Secret。

--addressing-style

string

请求地址的格式。取值范围如下:

  • virtual(默认值),表示虚拟托管模式

  • path,表示路径模式。

  • cname,表示自定义域名模式。

-c, --config-file

string

配置文件的路径。 默认值为~\\.ossutilconfig

--connect-timeout

int

客户端连接超时的时间。单位为秒,默认值为10。

-n, --dry-run

/

在不进行任何更改的情况下执行试运行。

-e, --endpoint

string

对外服务的访问域名。

-h, --help

/

显示帮助信息。

--language

string

显示的语言。

--loglevel

string

日志级别。取值范围如下:

  • off(默认值)

  • info

  • debug

--mode

string

鉴权模式。取值:

  • AK,表示访问密钥。

  • StsToken,表示临时安全凭证。

  • EcsRamRole,表示使用ECS实例角色(RAM Role)进行鉴权。

  • Anonymous,表示匿名访问。

--output-format

string

输出格式,默认值为raw。

--output-query

string

JMESPath查询条件。

--profile

string

指定配置文件里的profile。

-q, --quiet

/

安静模式,打印尽可能少的信息。

--read-timeout

int

客户端读写请求超时时间。单位为秒,默认值为20。

--region

string

数据中心所在的地域,配置值可设置为cn-hangzhou。

--retry-times

int

当错误发生时的重试次数。默认值为10。

--sign-version

string

请求使用的签名算法版本。取值:

  • v1

  • v4(默认值)

--skip-verify-cert

/

表示不校验服务端的数字证书。

-t, --sts-token

string

访问OSS使用的STS Token。

--proxy

string

指定代理服务器,

配置值可以为以下几种:

  • 直接配置:可以直接指定代理服务器的详细信息,例如:

    • http://proxy.example.com:8080

    • https://proxy.example.com:8443

  • env:表示使用环境变量 HTTP_PROXYHTTPS_PROXY 来获取代理服务器信息。用户需要在操作系统中配置这两个环境变量,例如:

    • HTTP_PROXY=http://proxy.example.com:8080

    • HTTPS_PROXY=https://proxy.example.com:8443

    配置这些环境变量后,将代理服务器选项的值设置为 env,系统将自动使用这些环境变量中的代理设置。

--log-file

string

指定日志输出文件,配置值为:

  • -:表示将日志输出到标准输出(Stdout)。

  • 文件路径:指定一个具体的文件路径,将日志输出到该文件。

如果未指定日志输出文件,输出到默认配置文件上。