简体   繁体   English

如何在软层对象存储中启用CORS

[英]How to enable CORS in softlayer object storage

I am using the Softlayer object storage and accessing my objects in the S3 bucket using SDK API from my Node.js application deployed on IBM Bluemix. 我正在使用Softlayer对象存储,并使用我从部署在IBM Bluemix上的Node.js应用程序中的SDK API通过S3存储桶访问我的对象。 I am able to insert the objects in the bucket but while accessing the object using SDK API I am getting the CORS error as below: 我可以将对象插入存储桶中,但是在使用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.

In AWS S3, we can configure the properties at the bucket level and we can explicitly enable CORS but then I don't see any such option in Softlayer. 在AWS S3中,我们可以在存储桶级别配置属性,并且可以显式启用CORS,但是在Softlayer中我看不到任何此类选项。

Please advise. 请指教。

Please review the guides at https://ibm-public-cos.github.io/crs-docs/crs-operations.html 请查看位于https://ibm-public-cos.github.io/crs-docs/crs-operations.html的指南

This is the official documentation for the Cloud Object Storage (S3) offering. 这是有关云对象存储(S3)产品的官方文档。

Object Storage uses standard S3 API and it seems you has chosen Object Storage S3 API so that you can use AWS SDK (php sdk in my case) to enable CORS and another policies at the bucket level. 对象存储使用标准的S3 API,似乎您选择了对象存储S3 API,以便可以使用AWS开发工具包(在我的情况下php sdk)在存储桶级别启用CORS和其他策略。

That's how I did it: 我就是这样的:

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

Regarding IBM Softlayer: I reported this issue about 3 month ago and I asked for code samples but they didnt neither solve my problem nor provide a concrete reference, that's a pitty because the operator recommended I have to post this issue in stackoverflow and wait for IBM developers answers since they cant to communicate to them, so docs is poor and customer support is disappointing. 关于IBM Softlayer:我大约3个月前报告了此问题,我要求提供代码示例,但是它们既没有解决我的问题,也没有提供具体的参考,这很可惜,因为操作员建议我必须将此问题发布在stackoverflow中,然后等待IBM开发人员会回答,因为他们无法与他们交流,因此文档质量很差,客户支持令人失望。

I hope this info help you. 希望此信息对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM