设置CORS配置时出现Google Storage ArgumentException

问题描述 投票:13回答:2

关注Google文档,使用Google云端存储控制台时:

mysef@myproject:~$ cat cors-json-file.json 
[ 
  {
    "origin": ["*"],
    "method": ["GET"],
    "maxAgeSeconds": 3600
  } 
]

然后我收到以下错误:

myself@myproject:~$ gsutil cors set cors-json-file.json gs://mybucket
Setting CORS on gs://mybucket/...
ArgumentException: JSON CORS data could not be loaded from: [ 
  {
    "origin": ["*"],
    "method": ["GET"],
    "maxAgeSeconds": 3600
  } 
]

删除“method”,“maxAgeSeconds”或添加“responseHeader”时出现相同的错误。

cors google-cloud-storage gsutil
2个回答
6
投票

经过这么多尝试,我最终将json文件修改为:

$ cat cors-json-file.json 
[{
    "origin": ["*"],
    "method": ["GET"],
    "maxAgeSeconds": 3600
}]

并且...它工作了!请注意,Google文档中的示例是我的第一个案例(使用[{2行)


1
投票

我有同样的问题,它是由使用的报价类型引起的。通过在纯文本编辑器中打开json文件并将引用更改为标准文件修复了问题。

© www.soinside.com 2019 - 2024. All rights reserved.