The documentation you are viewing is for Dapr v1.6 which is an older version of Dapr. For up-to-date documentation, see the latest version.

阿里云对象存储服务绑定规范

阿里云对象存储绑定组件的详细说明文档

配置

要设置阿里云对象存储绑定,请创建一个类型为bindings.alicloud.os的组件。 请参阅 本指南 了解如何创建和应用 secretstore 配置。 有关如何在 Dapr 组件中检索和使用 secret,请参阅 引用 secrets 指南。

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: alicloudobjectstorage
  namespace: default
spec:
  type: bindings.alicloud.oss
  version: v1
  metadata:
  - name: endpoint
    value: "[endpoint]"
  - name: accessKeyID
    value: "[key-id]"
  - name: accessKey
    value: "[access-key]"
  - name: bucket
    value: "[bucket]"

元数据字段规范

字段 必填 绑定支持 详情 示例
endpoint 输出 Alicloud OSS 端点。 https://oss-cn-hangzhou.aliyuncs.com
accessKeyID 输出 访问密钥 ID 凭据。
accessKey 输出 访问密钥凭据。
bucket 输出 存储桶名称

绑定支持

该组件支持如下操作的 输出绑定

创建对象

要执行创建对象操作,请使用POST方法和以下JSON调用绑定:

{
  "operation": "create",
  "data": "YOUR_CONTENT"
}

示例

保存到一个随机生成的UUID文件


curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\" }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>

curl -d '{ "operation": "create", "data": "Hello World" }' http://localhost:<dapr-port>/v1.0/bindings/<binding-name>


保存到特定文件


curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\", \"metadata\": { \"key\": \"my-key\" } }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>

curl -d '{ "operation": "create", "data": "Hello World", "metadata": { "key": "my-key" } }' http://localhost:<dapr-port>/v1.0/bindings/<binding-name>

元数据信息

对象键

默认情况下,Alicloud OSS输出绑定会自动生成一个UUID作为对象键。 您可以通过以下元数据来设置键:

{
    "data": "file content",
    "metadata": {
        "key": "my-key"
    },
    "operation": "create"
}

相关链接