Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix file upload filename issues (#1694)

Musthaq Ahamad7792dd4e13db
diff --git a/ts/packages/core/src/utils/fileUtils.ts b/ts/packages/core/src/utils/fileUtils.ts
index 145c1f91c..9d18d6cb9 100644
--- a/ts/packages/core/src/utils/fileUtils.ts
+++ b/ts/packages/core/src/utils/fileUtils.ts
@@ -11,7 +11,7 @@ const readFileContent = async (
try {
const content = require('fs').readFileSync(path);
return {
- fileName: path,
+ fileName: pathModule.basename(path) || `file_${Date.now()}.${path.split('.').pop()}`,
content: content.toString('base64'),
mimeType: 'application/octet-stream',
};
@@ -33,7 +33,7 @@ const readFileContentFromURL = async (
return {
content: content.toString('base64'),
mimeType,
- fileName: path,
+ fileName: pathModule.basename(path) || `file_${Date.now()}.${path.split('.').pop()}`,
};
};