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, andMD5 Hashto 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
- 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 ViewerorStorage Admin).
- 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).
- 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 is2023/report.csv, not justreport.csv. - Dynamic Usage: You typically construct this path using tokens.
- Example:
invoices//.
Outputs
- 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).
- Name
- The full file path (Object Key) of the retrieved object.
- Bucket
- The name of the bucket where the object was found.
- Size
- The size of the object in bytes. Useful for filtering (e.g., “If size > 0”).
- 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-typeequalsapplication/pdfbefore trying to merge it.
- The MIME type of the file (e.g.,
- 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.
- 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…”).
- Media Link
- A direct, authenticated download link to the object content.
- Self Link
- The canonical API resource link (used for advanced HTTP requests).
Example Use Cases
- 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. - Validate Uploads: Check the
MD5 Hashof a newly uploaded file to ensure it matches the source before triggering a database import. - Distribute Assets: Locate a marketing asset (PDF/Video) and generate a
Media Linkto share via Slack, avoiding the need to upload the heavy file to the chat directly. - Archive Data: Check the
Time Createdproperty; 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:
- Trigger: Scheduled Flow (Runs daily at 8:00 AM).
- Action: Format Date.
- Convert the current date (
Now) into the formatyyyy-MM-ddto match your filename structure.
- Convert the current date (
- 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.
- Bucket:
- Action: If Condition.
- Check if
Size(from Find Object) is Greater Than0(ensuring the file isn’t empty).
- Check if
- Action (True Branch): Send Email.
- To:
finance@company.com. - Subject: “Daily Transaction Report”.
- Attachments: Map the
File Contentstoken from the Find Object action.
- To:
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
- 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.
- Check File Size:
Before mapping
File Contentsto an email action, check theSizeoutput. Most email providers block attachments larger than 25MB. If the file is too large, send theMedia Linkinstead. - 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 justfile.txt.