Skip to content

Commit 64be766

Browse files
fix: return original filenames in readFileContent functions
- Add fileName field to readFileContent and readFileContentFromURL functions - Use pathModule.basename(path) to extract original filename instead of generating timestamped ones - Update getFileDataAfterUploadingToS3 to use fileName from fileData - Ensures S3 keys match database-stored filenames for proper consistency Co-Authored-By: himanshu@composio.dev <himanshu@composio.dev>
1 parent 1ad3bb7 commit 64be766

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

js/src/sdk/utils/processor/fileUtils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import { saveFile } from "../fileUtils";
77

88
const readFileContent = async (
99
path: string
10-
): Promise<{ content: string; mimeType: string }> => {
10+
): Promise<{ fileName: string; content: string; mimeType: string }> => {
1111
try {
1212
const content = require("fs").readFileSync(path);
1313
return {
14+
fileName: pathModule.basename(path),
1415
content: content.toString("base64"),
1516
mimeType: "application/octet-stream",
1617
};
@@ -21,14 +22,15 @@ const readFileContent = async (
2122

2223
const readFileContentFromURL = async (
2324
path: string
24-
): Promise<{ content: string; mimeType: string }> => {
25+
): Promise<{ fileName: string; content: string; mimeType: string }> => {
2526
const response = await axios.get(path, {
2627
responseType: "arraybuffer",
2728
});
2829
const content = Buffer.from(response.data);
2930
const mimeType =
3031
response.headers["content-type"] || "application/octet-stream";
3132
return {
33+
fileName: pathModule.basename(path),
3234
content: content.toString("base64"),
3335
mimeType,
3436
};
@@ -105,7 +107,7 @@ export const getFileDataAfterUploadingToS3 = async (
105107
);
106108

107109
return {
108-
name: pathModule.basename(path) || `${actionName}_${Date.now()}`,
110+
name: fileData.fileName,
109111
mimetype: fileData.mimeType,
110112
s3key: s3key,
111113
};

0 commit comments

Comments
 (0)