全部產品
Search
文件中心

Object Storage Service:option-object

更新時間:Aug 26, 2024

option-object命令用於跨域發送Options請求。

注意事項

  • 瀏覽器在發送跨域請求之前會發送一個preflight請求(Options)給OSS,並帶上特定的來源域、HTTP方法和header等資訊,以決定是否發送真正的請求。

  • Options請求是由瀏覽器自動根據是否跨域來決定是否發送。

命令格式

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

參數

類型

說明

--access-control-request-headers

string

在實際請求中會用到的除了簡單頭部之外的header。

--access-control-request-method

string

在實際請求中會用到的方法。

--bucket

string

Bucket名稱。

--key

string

Object完整路徑。

--origin

string

請求來源域,用於標識跨域請求。

說明

使用樣本

  • 發送一個preflight請求給儲存空間examplebucket中的example.txt 對象。

    ossutil api option-object --bucket examplebucket --key example.txt
  • 發送一個來源域www.example.com的preflight請求給儲存空間examplebucket中的example.txt 對象。

    ossutil api option-object --bucket examplebucket --key example.txt --origin www.example.com
  • 發送一個要求方法是PUT的preflight請求給儲存空間examplebucket中的 example.txt 對象。

    ossutil api option-object --bucket examplebucket --key example.txt --access-control-request-method PUT
  • 發送一個要求標頭是x-oss-test1的preflight請求給儲存空間examplebucket中的 example.txt 對象。

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