【问题标题】:Request and response format for IBM cloud storage object S3 APIIBM 云存储对象 S3 API 的请求和响应格式
【发布时间】:2017-06-14 10:07:02
【问题描述】:

我需要IBM云存储对象S3 API的相关请求和响应格式的信息。我一直在搜索API文档,发现它只支持XML响应格式。问题是,它支持Json格式响应吗?如果是的话,非常感谢提供有关我可以获得 Json 响应的对象和支持 API 的详细信息。

【问题讨论】:

    标签: api ibm-cloud object-storage ibm-cloud-storage


    【解决方案1】:

    当前Amazon S3 API is dated 2006-03-01。它将元数据封装在 XML 文档中,而不是 JSON 中。 IBM Cloud Object Storage service offers a common subset of the S3 API。为了兼容,该 API 需要遵循基于 XML 的 Amazon S3 API。

    您的问题的答案是不支持 JSON,只有 XML。

    【讨论】:

      【解决方案2】:

      Henrik 是正确的,因为 S3 API 是基于 XML 的,但根据使用的 SDK 或工具,可以获得 JSON、文本或表格响应。

      例如using the AWS CLI,您可以使用aws configure 设置响应类型,然后输出将被适当地格式化。

      JSON:

      $ aws s3api --endpoint-url=https://{endpoint} s3api list-buckets
      {
          "Owner": {
              "DisplayName": "{access-key}",
              "ID": "{access-key}"
          },
          "Buckets": [
              {
                  "CreationDate": "2016-11-09T16:43:29.957Z",
                  "Name": "bucket-1"
              },
              {
                  "CreationDate": "2017-06-13T23:47:18.169Z",
                  "Name": "bucket-2"
              },
              {
                  "CreationDate": "2017-05-01T02:36:34.385Z",
                  "Name": "bucket-3"
              },
          ]
      }
      

      文字:

      $ aws s3api --endpoint-url=https://{endpoint} s3api list-buckets
      BUCKETS 2016-11-09T16:43:29.957Z    bucket-1
      BUCKETS 2017-06-13T23:47:18.169Z    bucket-2
      BUCKETS 2017-05-01T02:36:34.385Z    bucket-3
      OWNER   {access-key}    {access-key}
      

      表:

      $ aws s3api --endpoint-url=https://{endpoint} s3api list-buckets
      ----------------------------------------------------------------------------
      |                                ListBuckets                               |
      +--------------------------------------------------------------------------+
      ||                                 Buckets                                ||
      |+----------------------------------+-------------------------------------+|
      ||           CreationDate           |                Name                 ||
      |+----------------------------------+-------------------------------------+|
      ||  2016-11-09T16:43:29.957Z        |  bucket-1                           ||
      ||  2017-06-13T23:47:18.169Z        |  bucket-2                           ||
      ||  2017-05-01T02:36:34.385Z        |  bucket-3                           ||
      |+----------------------------------+-------------------------------------+|
      ||                                  Owner                                 ||
      |+-----------------------------------+------------------------------------+|
      ||            DisplayName            |                ID                  ||
      |+-----------------------------------+------------------------------------+|
      ||            {access-key}           |           {access-key}             ||
      |+-----------------------------------+------------------------------------+|
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-11-17
        • 2018-12-03
        • 2021-12-14
        • 1970-01-01
        • 1970-01-01
        • 2017-06-16
        • 2019-01-18
        相关资源
        最近更新 更多