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

编程入门 行业动态 更新时间:2024-10-17 12:25:17
本文介绍了如何在软层对象存储中启用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 s3-api.us-geo.objectstorage.softlayer/<my bucket-name>/<my object-name>. No. 'Access Control-......Allow-Origin' header is present on the requested source. Origin '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,以便可以使用 AWS SDK(在我的情况下为PHP sdk)在存储桶级别启用CORS和其他策略.

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

本文发布于:2023-11-24 20:42:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626749.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   如何在   CORS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!