ai.uploadFile() filename parameter ignored in generated CDN URL

Hello,

I am building a Custom Function to generate CSV files dynamically and then email them to users. I am using the ai.uploadFile() method.

The Issue:
Although I am passing the filename argument to the function, the returned CDN URL always uses a UUID format (e.g., .../54b68041-bd95.csv) and completely discards the filename I provided.

Consequently, when I map this URL to the “Attachments” field in a Send Email block, the email attachment arrives named as the UUID (e.g., 54b68041-bd95.csv) rather than the intended filename (e.g., ClientName_WE_Date.csv).

Code Implementation:
Here is the code I am using. I verified via logs that ai.config.fileName contains the correct string (e.g., “csvFile”).

javascript

consturl =await ai.uploadFile(
ai.config.csvData,
'text/csv',
'utf-8',
ai.config.fileName// 4th parameter passed correctly
);

Key Observation:

I noticed that when files enter a workflow via an Email Trigger attachment, the generated CDN URL follows a structure that preserves the filename, looking something like:

.../app-data/[UUID]/[OriginalFileName].csv

However, ai.uploadFile() seems to generate:

.../app-data/[UUID]/functions/[UUID].csv

My Question:

Is there a specific way to force ai.uploadFile() to use the filename in the URL path (similar to email triggers) so that the Send Email block treats it correctly? Alternatively, is there a supported schema for the “Attachments” field in the Send Email block (e.g. an object with url and name properties) that allows us to override the filename?

I have created a minimal reproduction workflow to demonstrate this. You can copy it here.

https://app.mindstudio.ai/agents/csv-file-naming-flow-5653419a/remix

Thanks,

Aaron

Add to follow-up

Hi @AaronK,

Thanks for the post!

Customizing file names is not supported at the moment, but I do appreciate you letting us know. I’ve updated the post category to Feature Requests.

Roger that!

Thanks for the speedy response, Alex.

Always appreciated.

Aaron