Facing issues with PDF processing? The issue might be the MIME type... Check this out!
The Problem
You receive a PDF attachment via email. It looks like a perfectly normal PDF (e.g., invoice.pdf) and opens without any issues on your computer. But when you try to use it later in your Zenphi flow, it unexpectedly fails.
Check the MIME type! To confirm this is the issue, it helps to verify what the system is actually seeing. Simply add a Log to history action to your flow and map the incoming file's MIME type to it. Run a quick test. If the file is supposed to be a PDF, but your log shows application/octet-stream, this is exactly what is causing the error!
For example, if you try to pass this mislabeled file to Gemini, your flow will halt with this exact message:
Unable to submit request because it has a mimeType parameter with value application/octet-stream, which is not supported. Update the mimeType and try again.
Why does this happen?
When a file is sent over the internet, it includes a MIME type, a hidden label that tells the system what kind of file it is. A standard PDF should always be labeled application/pdf.
However, sometimes a file gets slapped with a generic "unknown" label: application/octet-stream (which basically means "generic raw data"). This happens for a few common reasons:
Aggressive Email Security: Corporate firewalls often strip original file labels when scanning attachments for malware, repackaging them as generic data.
API/System Handoffs: When files bounce between different servers, the metadata (like the MIME type) can get dropped in transit.
Forced Downloads: Some web platforms intentionally change the label to force a download rather than opening the file in a browser.
When strict actions in your flow (like Gemini) see this "unknown" label, they reject the file to prevent errors.
The Solution: The "Converter" Workaround
Instead of your flow failing, you can force Zenphi to rebuild the file with the correct label. To keep your flow clean, we will use a File Variable so that whether the file needs fixing or not, it always outputs perfectly to your next steps.
Here is how to set it up:
Step 1: Create a File Variable
At the beginning of your flow, create an empty File Variable (e.g., call it Final_PDF). This will hold the correct file for the rest of your flow.
Step 2: Add an ‘If Condition’
Right after your email/attachment trigger, add an If Condition action to check the attachment's MIME type.
When: [Mime Type]
Operator: Equal to
Value: application/octet-stream
Step 3: Build the 'True' Branch (The Fix)
If the file has the bad MIME type, we rebuild it here.
Add a Convert File to Base64 action and map your original email attachment to it.
Add a Convert Base64 to File action immediately after.
Map the output from the previous Base64 action.
Set your File Name.
Crucial Step: Manually type ‘application/pdf’ into the Content Type field.
Finally, map this newly converted file to your Final_PDF variable using ‘Set Variable’ action.
Step 4: Build the 'False' Branch (The Pass-Through)
If the file already has the correct MIME type, it will go down the False branch.
Simply map your original email attachment directly to your Final_PDF variable using ‘Set Variable’ action.
Step 5: Continue Your Flow!
Now, the branches merge back together! For all your future steps (like sending the file to Gemini), just use your Final_PDF variable. You will never face the "octet-stream" error again.
⚡ Quick Setup: Grab the Template! Want this setup ready to use right now? Go to this mini flow post: #Convert "application/octet-stream" to PDF Setup
Just download it, import it into your workspace, and then simply copy and paste the ready-made If condition directly into your own flow!