问题描述
我正在尝试通过以下代码将S3 API与Bluemix对象存储一起使用:
I'm trying to use S3 API with Bluemix object storage using the following code:
import boto3, pprint, sys;
s3 = boto3.Session().client(
service_name="s3",
region_name="us-geo",
endpoint_url="https://s3-api.us-geo.objectstorage.softlayer.net",
aws_access_key_id="auto-generated-apikey-<redacted>",
aws_secret_access_key="<redacted>");
pprint.pprint(s3.list_buckets());
但不断出现AccessDenied错误:
but keep getting AccessDenied error:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<Resource></Resource>
<RequestId><redacted></RequestId>
<httpStatusCode>403</httpStatusCode>
</Error>
我从服务凭据"选项卡中获取了aws_access_key_id和aws_secret_access_key.我为AWS S3使用了类似的代码,并且可以正常工作.我想念什么?
I took aws_access_key_id and aws_secret_access_key from the "Service Credentials" tab. I used similar code for AWS S3, and it worked. What am I missing?
推荐答案
启用了IAM的cos使用稍微不同的语法来创建客户端,而boto3库的fork支持这种语法.
The IAM-enabled cos uses a slightly different syntax for client creation that is supported by a fork of the boto3 library.
以下是文档中的示例: https://console.bluemix.net/docs/services/cloud-object-storage/libraries/python.html
Here’s an example in the docs: https://console.bluemix.net/docs/services/cloud-object-storage/libraries/python.html
这篇关于如何对Bluemix S3 Lite进行认证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!