Skip to main content

Read Object

Reads and retrieves the contents of an object (file) from a Google Cloud Storage bucket.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • GCS Client Id - The client identifier obtained from the Connect node. Optional if credentials are provided directly.
  • Bucket Name - The name of the bucket containing the object to read.
  • Object Name - The name (path) of the object to read from the bucket.

Output

  • Content - The content of the object as a string. Stored in message context as content.

Options

  • Credentials - Google Cloud service account credentials (optional). Use this instead of GCS Client Id for direct authentication without Connect node.

How It Works

The Read Object node retrieves the contents of an object from a Google Cloud Storage bucket. When executed, the node:

  1. Establishes connection using either GCS Client Id or provided credentials
  2. Validates the bucket name and object name
  3. Locates the specified object in the bucket
  4. Reads the complete object content
  5. Converts the content to a string
  6. Returns the content as output

Example

Reading a Text File

// After Connect node or with direct credentials
// Input:
// Bucket Name: "my-data-bucket"
// Object Name: "reports/sales-2024.csv"

// Output stored in message.content
// Access in next node:
const csvData = message.content;

Reading Files from Different Paths

// Reading a file in a subfolder structure
// Object Name: "data/processed/output.json"

// The content can be parsed if it's JSON
const jsonData = JSON.parse(message.content);
console.log(jsonData);

Reading Configuration Files

// Common use case: Reading config files from GCS
// Object Name: "config/app-settings.txt"

// Use the content in your automation
const settings = message.content.split('\n');
settings.forEach(setting => {
console.log(setting);
});

Requirements

  • Either a valid GCS Client Id from Connect node OR credentials provided directly
  • Valid bucket name that exists in Google Cloud Storage
  • Valid object name that exists in the specified bucket
  • Appropriate IAM permissions:
    • storage.objects.get permission
    • roles/storage.objectViewer or higher

Error Handling

The node will return specific errors in the following cases:

Error CodeDescription
ErrInvalidArgBucket Name or Object Name is empty or invalid
ErrInternalObject doesn't exist ("No such file")

Common error scenarios:

  • Empty or invalid GCS Client Id
  • Empty or invalid Bucket Name
  • Empty or invalid Object Name
  • Object does not exist in the specified bucket
  • Bucket doesn't exist
  • Insufficient permissions to read the object
  • Google Cloud Storage service errors
  • Network connectivity issues

Usage Notes

  • The object content is returned as a string
  • For text files (CSV, JSON, TXT), the content is directly usable
  • For binary files (images, PDFs), consider using alternative methods or download to local file
  • The node reads the entire object into memory - be cautious with very large files (over 100MB)
  • Object names can include folder-like paths using forward slashes
  • There's no actual folder structure in GCS - paths are part of object names
  • Works with all storage classes (Standard, Nearline, Coldline, Archive)

Tips for Effective Use

  • Use meaningful object names with path-like structure for organization
  • Implement error handling for missing files
  • For large files, consider downloading to local storage instead
  • Parse JSON/CSV content in subsequent JavaScript nodes
  • Use with Loop nodes to process multiple files
  • Combine with List Objects to read all files in a bucket
  • Cache frequently accessed content to reduce API calls

Common Errors and Solutions

Error: "Bucket Name cannot be empty"

  • Solution: Ensure the bucket name input is properly set and not empty
  • Check variable bindings and message context

Error: "Object Name cannot be empty"

  • Solution: Verify the object name is correctly specified
  • Check for typos in the object path

Error: "No such file"

  • Solution: Verify the object exists in the bucket using List Objects
  • Check the exact object name including path and file extension
  • Object names are case-sensitive

Object content is garbled or unreadable

  • Solution: The file might be binary (image, PDF, etc.)
  • For binary files, use Upload/Download operations instead
  • Ensure text files use UTF-8 encoding

Use Cases

Configuration Management

  • Read configuration files from centralized GCS bucket
  • Update app settings based on cloud-stored configs
  • Environment-specific configuration loading

Data Processing

  • Read CSV files for data processing workflows
  • Parse JSON data files for automation
  • Process log files stored in GCS

Report Generation

  • Read template files from GCS
  • Retrieve data files for report creation
  • Access historical data for analysis

Integration Workflows

  • Read files uploaded by external systems
  • Process incoming data from partner integrations
  • Retrieve shared files from multi-tenant buckets