Read file from cloud storage bucket
This lesson describe how to read a file from the cloud storage bucket
Last updated
This lesson describe how to read a file from the cloud storage bucket
Last updated
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.
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
Create a new function called ReadFileFromCloudStorageBucket.java.
Upload a file to the GCS bucket.
Set passed parameters as the name of the bucket and file path.
Call StorageApi.readFromBucket function with the above parameters.
This API returns Result. Verify the result and display number of bytes.
Return the response.