Konektor untuk Cloud Storage

Konektor Workflows yang menentukan fungsi bawaan yang digunakan untuk mengakses Cloud Storage dalam alur kerja.

Jelajahi lebih lanjut

Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:

Contoh kode

YAML

# This workflow demonstrates how to use the Cloud Storage connector.
# The workflow shows how to download/upload simple objects.
# The workflow creates a Cloud Storage bucket and then deletes it.
# Expected successful output: "SUCCESS"

- init:
    assign:
      - project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - bucket_name: "bucket-name"
      - object_name: "object-name"
# When alt=media, get object data.
- download_object_media:
    call: googleapis.storage.v1.objects.get
    args:
      bucket: ${bucket_name}
      object: ${object_name}
      alt: "media"
    result: object_data
# When 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
# When uploadType=media, upload object data.
# Use objects.update to udpate object metadata.
- upload_object_media:
    call: googleapis.storage.v1.objects.insert
    args:
      bucket: ${bucket_name}
      uploadType: "media"
      name: ${object_name}
      body: "hello world"
- create_bucket:
    call: googleapis.storage.v1.buckets.insert
    args:
      project: ${project_id}
      body:
        name: ${bucket_name}
- get_bucket:
    call: googleapis.storage.v1.buckets.get
    args:
      bucket: ${bucket_name}
- delete_bucket:
    call: googleapis.storage.v1.buckets.delete
    args:
      bucket: ${bucket_name}
- the_end:
    return: "SUCCESS"

Langkah selanjutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contoh Google Cloud.