如何在软层对象存储中启用CORS [英] How to enable CORS in softlayer object storage

查看:196
本文介绍了如何在软层对象存储中启用CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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. 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:

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中我看不到任何此类选项.

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.

请告知.

推荐答案

对象存储使用标准的S3 API,似乎您选择了对象存储S3 API,以便可以使用

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.

这就是我的方法:

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

关于IBM Softlayer:我大约3个月前报告了此问题,我要求提供代码示例,但是它们既没有解决我的问题,也没有提供具体的参考,这很可惜,因为操作员建议我必须将此问题发布在stackoverflow和等待IBM开发人员的答案,因为他们无法与他们交流,因此文档质量很差,客户支持令人失望.

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.

希望此信息对您有所帮助.

I hope this info help you.

这篇关于如何在软层对象存储中启用CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆