mirror of https://github.com/dapr/docs.git
Merge pull request #1329 from bhummerstone/bh-binding-examples
Additional cloud storage binding examples
This commit is contained in:
commit
39db98466d
|
@ -70,6 +70,85 @@ This component supports **output binding** with the following operations:
|
||||||
|
|
||||||
- `create`
|
- `create`
|
||||||
|
|
||||||
|
### Create file
|
||||||
|
|
||||||
|
To perform a create operation, invoke the GCP Storage Bucket binding with a `POST` method and the following JSON body:
|
||||||
|
|
||||||
|
> Note: by default, a random UUID is generated. See below for Metadata support to set the name
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"operation": "create",
|
||||||
|
"data": "YOUR_CONTENT"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
|
||||||
|
##### Save text to a random generated UUID file
|
||||||
|
|
||||||
|
{{< tabs Windows Linux >}}
|
||||||
|
{{% codetab %}}
|
||||||
|
On Windows, utilize cmd prompt (PowerShell has different escaping mechanism)
|
||||||
|
```bash
|
||||||
|
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\" }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d '{ "operation": "create", "data": "Hello World" }' \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
##### Save text to a specific file
|
||||||
|
|
||||||
|
{{< tabs Windows Linux >}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\", \"metadata\": { \"name\": \"my-test-file.txt\" } }" \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d '{ "operation": "create", "data": "Hello World", "metadata": { "name": "my-test-file.txt" } }' \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
|
##### Upload a file
|
||||||
|
|
||||||
|
To upload a file, pass the file contents as the data payload; you may want to encode this in e.g. Base64 for binary content.
|
||||||
|
|
||||||
|
Then you can upload it as you would normally:
|
||||||
|
|
||||||
|
{{< tabs Windows Linux >}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d "{ \"operation\": \"create\", \"data\": \"(YOUR_FILE_CONTENTS)\", \"metadata\": { \"name\": \"my-test-file.jpg\" } }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d '{ "operation": "create", "data": "$(cat my-test-file.jpg)", "metadata": { "name": "my-test-file.jpg" } }' \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
## Related links
|
## Related links
|
||||||
|
|
||||||
- [Basic schema for a Dapr component]({{< ref component-schema >}})
|
- [Basic schema for a Dapr component]({{< ref component-schema >}})
|
||||||
|
|
|
@ -29,8 +29,8 @@ spec:
|
||||||
value: *****************
|
value: *****************
|
||||||
- name: secretKey
|
- name: secretKey
|
||||||
value: *****************
|
value: *****************
|
||||||
- name: bucket
|
- name: sessionToken
|
||||||
value: mybucket
|
value: mysession
|
||||||
```
|
```
|
||||||
|
|
||||||
{{% alert title="Warning" color="warning" %}}
|
{{% alert title="Warning" color="warning" %}}
|
||||||
|
@ -54,6 +54,85 @@ This component supports **output binding** with the following operations:
|
||||||
|
|
||||||
- `create`
|
- `create`
|
||||||
|
|
||||||
|
### Create file
|
||||||
|
|
||||||
|
To perform a create operation, invoke the AWS S3 binding with a `POST` method and the following JSON body:
|
||||||
|
|
||||||
|
> Note: by default, a random UUID is generated. See below for Metadata support to set the name
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"operation": "create",
|
||||||
|
"data": "YOUR_CONTENT"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
|
||||||
|
##### Save text to a random generated UUID file
|
||||||
|
|
||||||
|
{{< tabs Windows Linux >}}
|
||||||
|
{{% codetab %}}
|
||||||
|
On Windows, utilize cmd prompt (PowerShell has different escaping mechanism)
|
||||||
|
```bash
|
||||||
|
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\" }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d '{ "operation": "create", "data": "Hello World" }' \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
##### Save text to a specific file
|
||||||
|
|
||||||
|
{{< tabs Windows Linux >}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\", \"metadata\": { \"key\": \"my-test-file.txt\" } }" \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d '{ "operation": "create", "data": "Hello World", "metadata": { "key": "my-test-file.txt" } }' \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
|
##### Upload a file
|
||||||
|
|
||||||
|
To upload a file, pass the file contents as the data payload; you may want to encode this in e.g. Base64 for binary content.
|
||||||
|
|
||||||
|
Then you can upload it as you would normally:
|
||||||
|
|
||||||
|
{{< tabs Windows Linux >}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d "{ \"operation\": \"create\", \"data\": \"(YOUR_FILE_CONTENTS)\", \"metadata\": { \"key\": \"my-test-file.jpg\" } }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```bash
|
||||||
|
curl -d '{ "operation": "create", "data": "$(cat my-test-file.jpg)", "metadata": { "key": "my-test-file.jpg" } }' \
|
||||||
|
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
|
||||||
|
```
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
## Related links
|
## Related links
|
||||||
|
|
||||||
- [Basic schema for a Dapr component]({{< ref component-schema >}})
|
- [Basic schema for a Dapr component]({{< ref component-schema >}})
|
||||||
|
|
Loading…
Reference in New Issue