Link Menu Expand (external link) Document Search Copy Copied

Find Object

Definition

The Find Object action in Google Cloud Storage enables you to locate a specific file (object) within a bucket and retrieve its complete details and content.

It is important to note that despite the name “Find,” this action is designed to Get a specific file where you already know the path (or can construct it dynamically). It does not “search” for files using wildcards (like *.jpg); for that, you would use “List Objects.”

Key capabilities include:

  • Retrieval: Fetches the actual file payload (File Contents) for processing, archiving, or emailing.
  • Validation: Returns critical metadata like Content-Type, Size, and MD5 Hash to verify integrity before processing.
  • Access Generation: Generates direct download links (Media Link) for external sharing.

This action is the standard method for reading a file from Google Cloud Storage into your Zenphi flow.


Inputs

  1. Connection
    • Purpose: Establishes the authentication required to access your Google Cloud Storage account.
    • Requirement: Select a connection that has sufficient permissions (e.g., Storage Object Viewer or Storage Admin).
  2. Bucket Name
    • Purpose: Specifies the container (bucket) where the file is located.
    • Practical Guidance:
    • Static: Type the exact bucket name (e.g., finance-datalake) if the location never changes.
    • Dynamic: Use the Token Picker to map a bucket name from a previous step (e.g., from a “List Buckets” action).
  3. Object Name
    • Purpose: Identifies the specific file to retrieve.
    • CRITICAL: This must be the Full Object Key (the full path), including all folder names.
    • Example: If your file is inside a folder named 2023, the Object Name is 2023/report.csv, not just report.csv.
    • Dynamic Usage: You typically construct this path using tokens.
    • Example: invoices//.

Outputs

  1. File Contents
    • Data Type: File Object
    • Description: The actual binary content of the file.
    • Workflow Utility: You can map this token directly to:
    • Email Attachments (Send the file).
    • Google Drive - Save File (Move the file).
    • Archive Actions (Zip the file).
  2. Name
    • The full file path (Object Key) of the retrieved object.
  3. Bucket
    • The name of the bucket where the object was found.
  4. Size
    • The size of the object in bytes. Useful for filtering (e.g., “If size > 0”).
  5. Content-type
    • The MIME type of the file (e.g., application/pdf, image/png, text/csv).
    • Use Case: Use an “If” condition to check if Content-type equals application/pdf before trying to merge it.
  6. MD5 Hash
    • A cryptographic hash of the file data.
    • Use Case: Compare this against a known hash to ensure the file was not corrupted during upload or transfer.
  7. Time Created / Updated
    • Timestamps indicating when the object was created or last modified.
    • Use Case: Archival logic (e.g., “If file is older than 30 days…”).
  8. Media Link
    • A direct, authenticated download link to the object content.
  9. Self Link
    • The canonical API resource link (used for advanced HTTP requests).

Example Use Cases

  1. Process Daily Reports: Calculate the filename for today’s report (e.g., data/2023-10-27.csv), retrieve it, and email it to the CFO.
  2. Validate Uploads: Check the MD5 Hash of a newly uploaded file to ensure it matches the source before triggering a database import.
  3. Distribute Assets: Locate a marketing asset (PDF/Video) and generate a Media Link to share via Slack, avoiding the need to upload the heavy file to the chat directly.
  4. Archive Data: Check the Time Created property; if the file is older than 1 year, move it to a “Cold Storage” bucket.

Example Scenario: The Morning Report

Goal: Your system generates a transaction report every night named with the current date (e.g., daily-logs/2023-10-27_transactions.csv). You need a workflow that wakes up at 8:00 AM, finds this specific file, and emails it to the Finance team.

Steps to Implement:

  1. Trigger: Scheduled Flow (Runs daily at 8:00 AM).
  2. Action: Format Date.
    • Convert the current date (Now) into the format yyyy-MM-dd to match your filename structure.
  3. Action: Find Object (Google Cloud Storage).
    • Bucket: finance-system-logs.
    • Object Name: daily-logs/ + [Formatted Date Token] + _transactions.csv.
    • Result: This dynamically constructs the path for today’s file.
  4. Action: If Condition.
    • Check if Size (from Find Object) is Greater Than 0 (ensuring the file isn’t empty).
  5. Action (True Branch): Send Email.
    • To: finance@company.com.
    • Subject: “Daily Transaction Report”.
    • Attachments: Map the File Contents token from the Find Object action.

Outcome: The workflow automatically calculates the correct filename for the day, retrieves the document, verifies it has data, and delivers it to the team without manual intervention.


Best Practices

  1. Handle Missing Files (404 Errors): If the file path you construct does not exist, this action will Fail and stop the flow.

    Tip: Handle Missing Files (Gracefully):

    If the file might not exist (e.g., on weekends), you don’t want the entire flow to crash.

    • Open the action’s settings, go to the Error Handling tab, and set the On Error behavior to Continue flow run.
    • Immediately after this action, add an If Condition to check if the action failed (e.g., check if it is faulted).
    • In the “True” branch (Error exists), you can send an email saying “No report found today.” In the “False” branch (Success), you proceed with processing the file.
  2. Check File Size: Before mapping File Contents to an email action, check the Size output. Most email providers block attachments larger than 25MB. If the file is too large, send the Media Link instead.
  3. Use Full Paths: Remember that Google Cloud Storage doesn’t have “real” folders—it just has long filenames with slashes. You must provide the full string (e.g., folder/subfolder/file.txt), not just file.txt.