You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用CLI配置IBM Cloud Object Storage Bucket CORS时遇错误求助

IBM Cloud Object Storage Bucket CORS配置报错问题

执行以下命令配置CORS时出现错误:

p@p:/home$ ibmcloud cos bucket-cors-put --bucket test --cors-configuration "./corsconfig.json"
FAILED
The value in flag '--cors-configuration' is invalid
NAME: 
   ibmcloud cos bucket-cors-put - Set the CORS configuration on a bucket

USAGE:
   ibmcloud cos bucket-cors-put --bucket BUCKET_NAME [--cors-configuration STRUCTURE] [--region REGION] [--output FORMAT] [--json]

OPTIONS:
   --bucket BUCKET_NAME            The name (BUCKET_NAME) of the bucket.
   --cors-configuration STRUCTURE  A STRUCTURE using JSON syntax in a file. See IBM Cloud Documentation.
   --region REGION                 The REGION where the bucket is present. If this flag is not provided, the program will use the default option specified in config.
   --output FORMAT                 Output FORMAT can be only json or text.
   --json                          [Deprecated] Output returned in raw JSON format.

使用的corsconfig.json内容:

{
"CORSRules": [
{
"AllowedHeaders": ["*"],
"AllowedMethods": ["GET"],
"AllowedOrigins": ["*"]
}
]
}

已尝试的操作:

  • 使用相对路径、绝对路径,路径加/不加引号
  • 切换区域至jp-tok(目标Bucket确实存在于该区域)

问题:仍无法解决错误,请问遗漏了什么?


可能的排查方向

  • 修正CLI参数格式:部分环境下,IBM Cloud COS CLI要求在配置文件路径前添加@符号,尝试修改命令:
    ibmcloud cos bucket-cors-put --bucket test --cors-configuration @./corsconfig.json --region jp-tok
    
  • 验证JSON文件合法性:用jq命令检查文件是否存在隐藏字符或语法错误:
    jq . corsconfig.json
    
    若输出正常则格式无问题,否则需修复文件。
  • 更新CLI及COS插件:旧版本可能存在参数解析bug,执行更新命令:
    ibmcloud update
    ibmcloud plugin update cloud-object-storage
    
  • 确认账号权限:当前账号需具备COS服务的Writer或更高权限,确保能修改Bucket配置。
  • 直接传入JSON内容:跳过文件,直接将JSON内容作为参数传入(注意终端的引号转义):
    ibmcloud cos bucket-cors-put --bucket test --cors-configuration '{"CORSRules":[{"AllowedHeaders":["*"],"AllowedMethods":["GET"],"AllowedOrigins":["*"]}]}' --region jp-tok
    

内容的提问来源于stack exchange,提问作者Pragati Bhattad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 17:10:45