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

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

组件格式

要设置阿里云对象存储绑定,需创建一个类型为 bindings.alicloud.oss 的组件。有关如何创建和应用 secretstore 配置,请参阅此指南。有关如何检索和使用 Dapr 组件的密钥,请参阅引用密钥指南。

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: alicloudobjectstorage
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]"

规范元数据字段

字段必填绑定支持详情示例
endpointYOutput阿里云 OSS 端点。https://oss-cn-hangzhou.aliyuncs.com
accessKeyIDYOutput访问密钥 ID 凭据。
accessKeyYOutput访问密钥凭据。
bucketYOutput存储桶的名称。

绑定支持

此组件支持输出绑定,支持以下操作:

Create object

要执行创建对象操作,请使用 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>

元数据信息

对象键

默认情况下,阿里云 OSS 输出绑定会自动生成一个 UUID 作为对象键。 您可以使用以下元数据设置键:

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

相关链接