Skip to content

Commit

Permalink
perf(markdown): export zip with name
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed Jul 18, 2022
1 parent 7af89c6 commit 96a7cb6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/modules/markdown/markdown.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { MarkdownYAMLProps } from './markdown.interface';
import { MarkdownService } from './markdown.service';
import JSZip from 'jszip';
import { join } from 'path';
import { Readable } from 'stream';
@Controller('markdown')
@ApiName
export class MarkdownController {
Expand All @@ -24,6 +23,7 @@ export class MarkdownController {
@ApiProperty({ description: '导出 Markdown YAML 数据' })
@HTTPDecorators.Bypass
@Header('Content-Type', 'application/zip')
@Header('Content-Disposition', 'attachment; filename=markdown.zip')
async exportMarkdown(@Query() { showTitle, slug, yaml }: ExportMarkdownDto) {
const { posts, pages } = await this.markdownService.getAllMarkdownData();

Expand Down Expand Up @@ -95,11 +95,14 @@ export class MarkdownController {
})
)

const readable = new Readable()
readable.push(await rtzip.generateAsync({ type: 'nodebuffer' }))
readable.push(null)
const buffer = await rtzip.generateAsync({ type: 'nodebuffer' })
return buffer

return readable
// const readable = new Readable()
// readable.push()
// readable.push(null)

// return readable

}
}

0 comments on commit 96a7cb6

Please sign in to comment.