Skip to content

Commit f708462

Browse files
authored
fix(files): skip zip and return plain .md when no embedded images (#4498)
* fix(files): skip zip and return plain .md when no embedded images * fix(files): use imageIds.length guard instead of assetMap.size * fix(files): move imageIds.length guard before async fetch to avoid unnecessary work
1 parent 38cbefd commit f708462

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • apps/sim/app/api/files/export/[id]

apps/sim/app/api/files/export/[id]/route.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,20 @@ export const GET = withRouteHandler(
8686
MAX_EMBEDDED_IMAGES
8787
)
8888

89-
logger.info('Exporting markdown with embedded images', { id, imageCount: imageIds.length })
89+
logger.info('Exporting markdown', { id, imageCount: imageIds.length })
90+
91+
if (imageIds.length === 0) {
92+
const mdName = safeFilename(record.originalName)
93+
const mdBytes = Buffer.from(mdContent, 'utf-8')
94+
return new NextResponse(new Uint8Array(mdBytes), {
95+
status: 200,
96+
headers: {
97+
'Content-Type': 'text/markdown; charset=utf-8',
98+
'Content-Disposition': `attachment; filename="${mdName}"`,
99+
'Content-Length': String(mdBytes.length),
100+
},
101+
})
102+
}
90103

91104
const fetchResults = await Promise.allSettled(
92105
imageIds.map(async (imageId) => {

0 commit comments

Comments
 (0)