5.1 KiB
		
	
	
	
	
	
			
		
		
	
	| type | title | linkTitle | description | 
|---|---|---|---|
| docs | GCP Storage Bucket binding spec | GCP Storage Bucket | Detailed documentation on the GCP Storage Bucket binding component | 
Component format
To setup GCP Storage Bucket binding create a component of type bindings.gcp.bucket. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration.
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
  namespace: <NAMESPACE>
spec:
  type: bindings.gcp.bucket
  version: v1
  metadata:
  - name: bucket
    value: mybucket
  - name: type
    value: service_account
  - name: project_id
    value: project_111
  - name: private_key_id
    value: *************
  - name: client_email
    value: name@domain.com
  - name: client_id
    value: '1111111111111111'
  - name: auth_uri
    value: https://accounts.google.com/o/oauth2/auth
  - name: token_uri
    value: https://oauth2.googleapis.com/token
  - name: auth_provider_x509_cert_url
    value: https://www.googleapis.com/oauth2/v1/certs
  - name: client_x509_cert_url
    value: https://www.googleapis.com/robot/v1/metadata/x509/<project-name>.iam.gserviceaccount.com
  - name: private_key
    value: PRIVATE KEY
{{% alert title="Warning" color="warning" %}} The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}}
Spec metadata fields
| Field | Required | Binding support | Details | Example | 
|---|---|---|---|---|
| bucket | Y | Output | The bucket name | "mybucket" | 
| type | Y | Output | Tge GCP credentials type | "service_account" | 
| project_id | Y | Output | GCP project id | projectId | 
| private_key_id | Y | Output | GCP private key id | "privateKeyId" | 
| private_key | Y | Output | GCP credentials private key. Replace with x509 cert | 12345-12345 | 
| client_email | Y | Output | GCP client email | "client@email.com" | 
| client_id | Y | Output | GCP client id | 0123456789-0123456789 | 
| auth_uri | Y | Output | Google account OAuth endpoint | https://accounts.google.com/o/oauth2/auth | 
| token_uri | Y | Output | Google account token uri | https://oauth2.googleapis.com/token | 
| auth_provider_x509_cert_url | Y | Output | GCP credentials cert url | https://www.googleapis.com/oauth2/v1/certs | 
| client_x509_cert_url | Y | Output | GCP credentials project x509 cert url | https://www.googleapis.com/robot/v1/metadata/x509/<PROJECT_NAME>.iam.gserviceaccount.com | 
Binding support
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
{
  "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)
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\" }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
{{% /codetab %}}
{{% codetab %}}
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 %}}
curl -d "{ \"operation\": \"create\", \"data\": \"Hello World\", \"metadata\": { \"name\": \"my-test-file.txt\" } }" \
      http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
{{% /codetab %}}
{{% codetab %}}
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 %}}
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 %}}
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
- [Basic schema for a Dapr component]({{< ref component-schema >}})
 - [Bindings building block]({{< ref bindings >}})
 - [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}})
 - [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}})
 - [Bindings API reference]({{< ref bindings_api.md >}})