Trillo Workbench Lessons
  • Introduction
    • Sample Application
  • Introduction to Lessons
    • IDE Lessons
    • Annotated Directory Structure
  • New classes using workbench UI
  • Save many records into tables using the workbench UI
  • New function using Workbench UI
  • Introduction to Code Lessons
    • Anatomy of Trillo Function
  • Begin Code Lessons
    • Paginated list
    • Pagination using SQL Query
    • DataIterator
    • Read file from cloud storage bucket
    • Generating signed URL for a file download
    • Import a CSV file from bucket into BigQuery
    • Query a dataset of BigQuery
    • Using an Document AI Processor
    • Chat using GenAI
    • Function calling another function
    • Accessing Runtime Context
    • Write a workflow (pipeline for data processing)
  • Appendixes
    • ServerlessFunction
    • Map, List and Tree
    • Logs and Audit Logs
    • DataRequest Class
    • DataResponse Class
    • DataIterator Class
    • Result
Powered by GitBook
On this page
  1. Begin Code Lessons

Read file from cloud storage bucket

This lesson describe how to read a file from the cloud storage bucket

PreviousDataIteratorNextGenerating signed URL for a file download

Last updated 1 year ago

In this example, the function code accepts the bucketName and the sourceFilePath

As input parameters. It fetches the file as a byte array (base64 encoded in a remote call due to JSON serialization) format and returns by wrapping it inside the Result class. If there is a failure then the failed Result is returned.

Code: /lessons/Read_File_from_Cloud_Storage_Bucket

Prerequisite

In this lesson it is assumed that you have a file available in the cloud storage bucket. The file is included in the lesson’s directory. The bucket view is shown below.

Steps

  1. Create a new function called ReadFileFromCloudStorageBucket.java.

  2. Upload a file to the GCS bucket.

  3. Set passed parameters as the name of the bucket and file path.

  4. Call StorageApi.readFromBucket function with the above parameters.

  5. This API returns Result. Verify the result and display number of bytes.

  6. Return the response.