【问题标题】:How to enable CORS in softlayer object storage如何在 softlayer 对象存储中启用 CORS
【发布时间】:2017-02-26 15:42:57
【问题描述】:

我正在使用 Softlayer 对象存储并使用 SDK API 从部署在 IBM Bluemix 上的 Node.js 应用程序访问 S3 存储桶中的对象。我能够将对象插入存储桶中,但是在使用 SDK API 访问对象时,出现如下 CORS 错误:

XMLHttpRequest cannot load https://s3-api.us-geo.objectstorage.softlayer.net/<my bucket-name>/<my object-name>. No. 'Access Control-......Allow-Origin' header is present on the requested source. Origin 'http://localhost:6009' is therefore not allowed.

在 AWS S3 中,我们可以在存储桶级别配置属性,我们可以显式启用 CORS,但是我在 Softlayer 中看不到任何此类选项。

请指教。

【问题讨论】:

    标签: ibm-cloud ibm-cloud-infrastructure object-storage


    【解决方案1】:

    请在https://ibm-public-cos.github.io/crs-docs/crs-operations.html查看指南

    这是 Cloud Object Storage (S3) 产品的官方文档。

    【讨论】:

      【解决方案2】:

      Object Storage 使用标准 S3 API,您似乎选择了 Object Storage S3 API,以便您可以使用 AWS SDK (php sdk in my case) 在存储桶级别启用 CORS 和其他策略。

      我就是这样做的:

      $s3Client->putBucketCors([
          'Bucket' => 'your-object-storage-bucket-name',
          'CORSConfiguration' => [
              'CORSRules' => [
                  [
                      'AllowedHeaders' => ['*'],
                      'AllowedMethods' => ['GET', 'POST', 'PUT', 'DELETE'],
                      'AllowedOrigins' => ['*'],
                  ]
              ],
          ],
      ]);
      

      关于 IBM Softlayer:我大约 3 个月前报告了这个问题,我要求提供代码示例,但他们既没有解决我的问题,也没有提供具体的参考,这很遗憾,因为运营商建议我必须在 stackoverflow 中发布这个问题并且等待 IBM 开发人员的答复,因为他们无法与他们交流,因此文档很差,客户支持也令人失望。

      希望这些信息对你有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多