All Products
Search
Document Center

Object Storage Service:option-object

Last Updated:Mar 20, 2026

Sends a CORS (Cross-Origin Resource Sharing) preflight OPTIONS request to an object to verify whether the cross-origin request is permitted by OSS.

Usage notes

Before a cross-origin request is sent, the browser sends a preflight OPTIONS request to OSS. The request carries origin, HTTP method, and header information, which OSS evaluates against the bucket's CORS rules:

ParameterMatched against CORS rule field
--originAllowedOrigins
--access-control-request-methodAllowedMethods
--access-control-request-headersAllowedHeaders

If any value does not match the CORS rules, none of the CORS response headers are returned.

The browser determines automatically whether a preflight request is needed. Use this command to test or debug CORS rules manually from the command line.

Command syntax

ossutil api option-object --bucket <value> --key <value> [flags]

Parameters

ParameterTypeRequiredDescription
--bucketstringYesThe name of the bucket.
--keystringYesThe full path of the object.
--originstringNoThe origin of the cross-origin request. Matched against AllowedOrigins in the CORS configuration.
--access-control-request-methodstringNoThe HTTP method to be used in the actual cross-origin request. Matched against AllowedMethods in the CORS configuration.
--access-control-request-headersstringNoThe custom request headers to be included in the actual cross-origin request. Matched against AllowedHeaders in the CORS configuration.

For supported global flags, see Global command-line options.

Examples

Test a specific origin and HTTP method

The following command tests whether PUT requests from www.example.com are allowed on example.txt in examplebucket:

ossutil api option-object --bucket examplebucket --key example.txt \
  --origin www.example.com \
  --access-control-request-method PUT

Send a basic OPTIONS request

ossutil api option-object --bucket examplebucket --key example.txt

Test with a custom request header

ossutil api option-object --bucket examplebucket --key example.txt \
  --access-control-request-headers x-oss-test1

Test with an origin only

ossutil api option-object --bucket examplebucket --key example.txt \
  --origin www.example.com

What's next