The cors-options command is used to test whether a bucket has cross-origin resource sharing (CORS) configured.

Note
  • The commands described in this topic apply to Linux. To use the commands in other systems, replace ./ossutil in the command with the actual executable program name. For example, you can use the help command in 32-bit Windows systems by running ossutil32.exe help.
  • For more information about CORS, see Set CORS rules.
  • For more information about commands used to configure CORS, see cors.

Command syntax

./ossutil cors-options --acr-method <value> --origin <value> --acr-headers <value> oss://bucket/[object]
The cors-options command is used to send an HTTP OPTIONS request to OSS to test whether a cross-origin request is allowed.
  • --acr-method: specifies the value of the Access-Control-Request-Method header in an HTTP request. Valid values: GET, PUT, POST, DELETE, and HEAD.
  • --origin: specifies the value of the Origin field in the HTTP header. This parameter specifies the origin where a cross-origin request is from and is used to identify the origin that you will allow to access your bucket.
  • --acr-headers: specifies the value of the Access-Control-Request-Headers field in the HTTP header. This parameter specifies actual headers except commonly used headers. To specify multiple headers, separate different headers with commas (,) and enclose the headers with double quotation marks ("). Example: --acr-headers "header1,header2,header3".

Examples

./ossutil cors-options --acr-method  put --origin "www.aliyun.com" oss://bucket1
Access-Control-Allow-Methods: GET, POST, PUT
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 0

Common options

The following table describes the options you can add to the cors-options command.
Option Description
--origin Specifies the value of the Origin field in the HTTP header. This parameter specifies the origin where a cross-origin request is from and is used to identify the origin that you will allow to access your bucket.
--acr-method Specifies the value of the Access-Control-Request-Method header in an HTTP request. Valid values: GET, PUT, POST, DELETE, and HEAD.
--acr-headers Specifies the value of the Access-Control-Request-Headers header in an HTTP request. This option value indicates header fields, except simple ones, to be used in an actual request. To specify multiple headers, separate different headers with commas (,) and enclose the headers with double quotation marks ("). Example: --acr-headers "header1,header2,header3."
--encoding-type Specifies the method used to encode the object name. If this option is specified, this value must be url. If this option is not specified, the object name is not encoded. Bucket names cannot be URL-encoded.
--loglevel Specifies the log level. The default value is null, indicating that no log files are generated. Valid values:
  • info: generates prompt logs.
  • debug: generates detailed logs that contain corresponding HTTP request and response information.
--proxy-host Specifies the URL of the proxy server. HTTP, HTTPS, and SOCKS5 proxies are supported. An example of the URL is http://120.79. **.**:3128 or socks5://120.79. **. **:1080.
--proxy-user Specifies the username for the proxy server. The default value is null.
--proxy-pwd Specifies the password for the proxy server. The default value is null.
Note For more information about common options, see View all supported options.