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

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

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

配置

要设置阿里云对象存储绑定,请创建一个类型为bindings.alicloud.os的组件。 See this guide on how to create and apply a secretstore configuration. See this guide on referencing secrets to retrieve and use the secret with Dapr components.

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]"

元数据字段规范

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

绑定支持

字段名为 ttlInSeconds

创建对象

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

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

Example

保存到一个随机生成的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"
}

相关链接