Connettore per Cloud Storage

Connettore Workflows che definisce la funzione integrata utilizzata per accedere a Cloud Storage all'interno di un flusso di lavoro.

Per saperne di più

Per la documentazione dettagliata che include questo esempio di codice, consulta quanto segue:

Esempio di codice

YAML

# This workflow demonstrates how to use the Cloud Storage connector:
# Create a bucket and upload an object to the bucket
# Delete the bucket and the object
# Expected output: "SUCCESS"
- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - bucket_name: "BUCKET_NAME"  # replace BUCKET_NAME placeholder
      - object_name: "FILE_NAME.txt"  # replace FILE_NAME placeholder
- create_bucket:
    call: googleapis.storage.v1.buckets.insert
    args:
      project: ${project_id}
      body:
        name: ${bucket_name}
- upload_object_media:
    call: googleapis.storage.v1.objects.insert
    args:
      bucket: ${bucket_name}
      uploadType: "media"  # uploads object data
      name: ${object_name}
      body: "hello world"
- download_object_media:
    call: googleapis.storage.v1.objects.get
    args:
      bucket: ${bucket_name}
      object: ${object_name}
      alt: "media"  # gets object data
    result: object_data
# If `alt` is not set, get metadata
- get_object_metadata:
    call: googleapis.storage.v1.objects.get
    args:
      bucket: ${bucket_name}
      object: ${object_name}
    result: object_metadata
- get_bucket:
    call: googleapis.storage.v1.buckets.get
    args:
      bucket: ${bucket_name}
- delete_object:
    call: googleapis.storage.v1.objects.delete
    args:
      bucket: ${bucket_name}
      object: ${object_name}
- delete_bucket:
    call: googleapis.storage.v1.buckets.delete
    args:
      bucket: ${bucket_name}
- the_end:
    return: "SUCCESS"

Passaggi successivi

Per cercare e filtrare esempi di codice per altri prodotti Google Cloud, consulta Browser di esempio Google Cloud.