This commit is contained in:
Bastian Wagner
2026-03-13 15:23:33 +01:00
parent 7271c7bc79
commit 084decfc10
2 changed files with 16 additions and 12 deletions

View File

@@ -17,11 +17,11 @@ export class PdfController {
}
@Post('keyhandover')
@Header('Content-Type', 'application/pdf')
// @Header('Content-Type', 'application/pdf')
async generatePdf(@Res() res: Response, @Body() dto: KeyHandoverDto): Promise<void> {
const pdfBuffer = await this.pdfService.generatePdf(dto);
res.setHeader('Content-Disposition', 'inline; filename="test.pdf"');
// res.setHeader('Content-Disposition', 'inline; filename="test.pdf"');
res.send(pdfBuffer);
}

View File

@@ -4,22 +4,26 @@ import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
@Injectable()
export class MinioService {
private readonly client: S3Client;
private client: S3Client;
constructor(private configService: ConfigService) {
this.client = new S3Client({
region: 'us-east-1',
endpoint: this.configService.get('MINIOHOST') || '',
credentials: {
accessKeyId: this.configService.get('MINIOUSER') || '',
secretAccessKey: this.configService.get('MINIOACCESSKEY') || '',
},
forcePathStyle: true,
});
}
async uploadPdf(bucket: string, key: string, pdfBuffer: Buffer): Promise<void> {
if (!this.client) {
this.client = new S3Client({
region: 'us-east-1',
endpoint: this.configService.get('MINIOHOST') || '',
credentials: {
accessKeyId: this.configService.get('MINIOUSER') || '',
secretAccessKey: this.configService.get('MINIOACCESSKEY') || '',
},
forcePathStyle: true,
});
console.log(this.configService.get('MINIOHOST'))
}
await this.client.send(
new PutObjectCommand({
Bucket: bucket,