Skip to content

Commit 25a219d

Browse files
committed
chore: refactor
1 parent bd78a0b commit 25a219d

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

services/workflows-service/src/document/document.service.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,15 +1181,24 @@ export class DocumentService {
11811181
documentSchema,
11821182
);
11831183
const filesWithBase64 = await Promise.all(
1184-
files.map(async ({ imageUrl, file, ...fileData }) => ({
1185-
...fileData,
1186-
imageUrl,
1187-
fileName: file.fileName,
1188-
base64:
1189-
this.isCsv(fileData) && imageUrl
1190-
? await this.fetchCsvFromUrlAndCovertToBase64(imageUrl)
1191-
: undefined,
1192-
})),
1184+
files.map(async ({ imageUrl, file, ...fileData }) => {
1185+
let base64: string | undefined;
1186+
1187+
if (this.isCsv(fileData) && imageUrl) {
1188+
try {
1189+
base64 = await this.fetchCsvFromUrlAndCovertToBase64(imageUrl);
1190+
} catch (error) {
1191+
console.error(`Failed to fetch CSV and convert to base64 file ${file.id}:`, error);
1192+
}
1193+
}
1194+
1195+
return {
1196+
...fileData,
1197+
imageUrl,
1198+
fileName: file.fileName,
1199+
base64,
1200+
};
1201+
}),
11931202
);
11941203

11951204
return {

0 commit comments

Comments
 (0)