From 231049a368ad71127f64cb1ae0a72a87cc497baa Mon Sep 17 00:00:00 2001 From: Ben Hummerstone Date: Mon, 22 Mar 2021 15:30:36 +0000 Subject: [PATCH] added examples for gcp storage bucket binding --- .../supported-bindings/gcpbucket.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/gcpbucket.md b/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/gcpbucket.md index e52a252cb..b00f19822 100644 --- a/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/gcpbucket.md +++ b/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/gcpbucket.md @@ -70,6 +70,85 @@ This component supports **output binding** with the following operations: - `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:/v1.0/bindings/ + ``` + {{% /codetab %}} + + {{% codetab %}} + ```bash + curl -d '{ "operation": "create", "data": "Hello World" }' \ + http://localhost:/v1.0/bindings/ + ``` + {{% /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:/v1.0/bindings/ + ``` + {{% /codetab %}} + + {{% codetab %}} + ```bash + curl -d '{ "operation": "create", "data": "Hello World", "metadata": { "name": "my-test-file.txt" } }' \ + http://localhost:/v1.0/bindings/ + ``` + {{% /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:/v1.0/bindings/ + ``` + {{% /codetab %}} + + {{% codetab %}} + ```bash + curl -d '{ "operation": "create", "data": "$(cat my-test-file.jpg)", "metadata": { "name": "my-test-file.jpg" } }' \ + http://localhost:/v1.0/bindings/ + ``` + {{% /codetab %}} + +{{< /tabs >}} + ## Related links - [Basic schema for a Dapr component]({{< ref component-schema >}})