Ibm cloud IBM云对象存储凭据

Ibm cloud IBM云对象存储凭据,ibm-cloud,object-storage,ibm-cloud-storage,Ibm Cloud,Object Storage,Ibm Cloud Storage,我正在尝试设置一个Raspberry Pi,它连接到IBM云上的对象存储服务。在所有关于对象存储的教程中,凭据的格式如下: { "auth_url": "https://identity.open.softlayer.com", "project": "object_storage_xxxxxxxx_xxxx_xxxx_b35a_6d007e3f9118", "projectId": "512xxxxxxxxxxxxxxxxxxxxxe00fe4e1", "region":

我正在尝试设置一个Raspberry Pi,它连接到IBM云上的对象存储服务。在所有关于对象存储的教程中,凭据的格式如下:

{
  "auth_url": "https://identity.open.softlayer.com",
  "project": "object_storage_xxxxxxxx_xxxx_xxxx_b35a_6d007e3f9118", 
  "projectId": "512xxxxxxxxxxxxxxxxxxxxxe00fe4e1", 
  "region": "dallas",
  "userId": "e8c19efxxxxxxxxxxxxxxxxxxx91d53e",
  "username": "admin_1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa66",
  "password": "fTxxxxxxxxxxw8}l",
  "domainId": "15xxxxxxxxxxxxxxxxxxxxxxxxxxxx2a", 
  "domainName": "77xxx3",
  "role": "admin"
}
其中给出了以下评论:

在IBM Cloud web界面内,您可以创建或读取现有凭据。如果您的程序在IBM Cloudfoundry或Kubernetes上运行,则还可以通过VCAP环境变量获得凭据

然而,我并不是在IBMCloud上运行Python脚本,而是在向其发送数据的RPi上运行。在我的对象存储服务中,有一个服务凭据选项卡,其形式如下:

{
  "apikey": "XXXXXX-_XXXXXXXXXXXXXXXXXX_XXXXXX",
  "endpoints": "https://cos-service.bluemix.net/endpoints",
  "iam_apikey_description": "Auto generated apikey during resource-key 
    operation for Instance - crn:v1:bluemix:public:cloud-object-
    storage:global:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "iam_apikey_name": "auto-generated-apikey-XXXXXXXX-XXXX-XXXX-XXXX-
    XXXXXXXXXXXX",
  "iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Writer",
  "iam_serviceid_crn": "crn:v1:bluemix:public:iam-
identity::XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX::serviceid:ServiceId-
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "resource_instance_id": "crn:v1:bluemix:public:cloud-object-
storage:global:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

那么,如何找到所需的凭据,以便使用Python中的SWIFT协议将数据从Raspberry Pi发送到对象存储服务?

您可以使用IBM的S3对象存储协议,而不是我认为不受支持的SWIFT。有一种方法可以使这变得容易

例如,要连接到cos s3:

import ibm_boto3
from ibm_botocore.client import Config

api_key = 'API_KEY'
service_instance_id = 'RESOURCE_INSTANCE_ID'
auth_endpoint = 'https://iam.bluemix.net/oidc/token'
service_endpoint = 'https://s3-api.us-geo.objectstorage.softlayer.net'

s3 = ibm_boto3.resource('s3',
                      ibm_api_key_id=api_key,
                      ibm_service_instance_id=service_instance_id,
                      ibm_auth_endpoint=auth_endpoint,
                      config=Config(signature_version='oauth'),
                      endpoint_url=service_endpoint)
IBM boto3库与用于连接amazon s3对象存储的boto3库非常相似。主要的区别在于我在上面展示的初始连接的设置。完成后,您可以在网上找到大量使用boto3的示例,以下是一个:

# Upload a new file
data = open('test.jpg', 'rb')
s3.Bucket('my-bucket').put_object(Key='test.jpg', Body=data)

发件人:

您可能需要查看下面的问题/答案列表。基本上,您需要的是一个访问密钥和密钥,以添加到Python代码中,从而连接到您的云对象存储帐户


这确实是一个运作良好的图书馆。现在使用以下命令:Hi@chris,有没有办法在完成操作后关闭此资源?请注意,支持accessKey和secretKey的常规对象存储之间存在差异。然而,当使用Lite计划时,客户端没有得到任何一个,只有一个apiKey