From ab0df696456e0503ab2bb6c72421c442bc84d3fb Mon Sep 17 00:00:00 2001 From: xavier geerinck Date: Sat, 30 Jan 2021 17:51:15 +0100 Subject: [PATCH] Rework Azure Blob Storage documentation to be more clear (#1122) Co-authored-by: Yaron Schneider --- .../supported-bindings/blobstorage.md | 52 +++++++++++++++++-- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/blobstorage.md b/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/blobstorage.md index 02a38eac2..5df555368 100644 --- a/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/blobstorage.md +++ b/daprdocs/content/en/operations/components/setup-bindings/supported-bindings/blobstorage.md @@ -40,20 +40,62 @@ The above example uses secrets as plain strings. It is recommended to use a secr To perform a create blob operation, invoke the Azure Blob Storage 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": { - "field1": "value1" - } + "data": "YOUR_CONTENT" } ``` #### Example: -```bash +> We escape since ' is not supported on Windows +> On Windows, utilize CMD (PowerShell has different escaping mechanism) -curl -d '{ "operation": "create", "data": { "field1": "value1" }}' \ +**Saving to a random generated UUID file** + +```bash +curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\" }" \ + http://localhost:/v1.0/bindings/ +``` + +**Saving to a specific file** + +```bash +curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\", \"metadata\": { \"blobName\": \"my-test-file.txt\" } }" \ + http://localhost:/v1.0/bindings/ +``` + +**Saving a file** + +To upload a file, encode it as Base64 and let the Binding know to deserialize it: + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: + namespace: +spec: + type: bindings.azure.blobstorage + version: v1 + metadata: + - name: storageAccount + value: myStorageAccountName + - name: storageAccessKey + value: *********** + - name: container + value: container1 + - name: decodeBase64 + value: "true" +``` + +Then you can upload it as you would normally: + +```bash +curl -d "{ \"operation\": \"create\", \"data\": \"YOUR_BASE_64_CONTENT\", \"metadata\": { \"blobName\": \"my-test-file.jpg\" } }" \ http://localhost:/v1.0/bindings/ ```