BLOCKS Reference

Google Cloud

Upload to GCS from variable

Overview

This BLOCK uploads the contents of a variable as a file to GCS.

It converts the contents of the variable according to its file format property. The six available formats are as follows:

File format Explanation
(none)

Writes the contents of the variable as is to the file. The variable must contain a STRING, otherwise the BLOCK will fail.

YAML

Converts the contents of the variable to YAML and writes it to the file.

JSON

Converts the contents of the variable to JSON and writes it to the file.

CSV

Converts the contents of the file to CSV and writes it to the file.

  • The contents of the variable must be an array of objects in order to use this format.
  • The file will be written as a comma-delimited CSV file with a header line.
  • The names for each column in the header line are taken from the name in the key for each pair in the first object.

The following example shows how to use the Construct object BLOCK to prepare an array of objects.

Construct object BLOCK example for writing a CSV file from a variable

(Click image to enlarge)

Processing the Upload to GCS from variable BLOCK with a variable containing this data will write the following CSV file to GCS (Note: the input variable property would be set to _.data):

Col1,Col2,Col3
abc,123,1.23
xyz,456,4.56
Newline delimited JSON

Converts the contents of the variable to newline delimited JSON and writes it to the file.

  • If the variable contains array data, each element will be converted into one line of JSON (the number of elements will be the number of rows in the file).
  • If the variable contains sometime other than array data, the data will be converted to one line of JSON (the file will have one line).
Binary (Base64)

Assuming the variable contains a Base64 encoded string, the decoded string will be written to the file. The variable must contain string data, otherwise the BLOCK will fail.

Properties

Property Explanation
BLOCK name

Configure the name displayed on this BLOCK.

GCP service account

Select the GCP service account to use with this BLOCK.

Destination GCS URL

Designate the GCS URL that the file will be uploaded to (Example: gs://magellan-sample/sample.yaml).

File format

Designate the format of the file that will be uploaded. The contents of the variable will be converted according to this setting to create the file.

  • (none)
  • YAML
  • JSON
  • CSV
  • Newline delimited JSON
  • Binary (Base64)

Refer to the explanation in the Overview section for more details on each file format.

BLOCK memos

Make notes about this BLOCK.

Input variable

Designate the variable whose contents will be uploaded as a file to GCS.

この情報は役に立ちましたか?