config
This commit is contained in:
@@ -17,11 +17,11 @@ export class PdfController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('keyhandover')
|
@Post('keyhandover')
|
||||||
@Header('Content-Type', 'application/pdf')
|
// @Header('Content-Type', 'application/pdf')
|
||||||
async generatePdf(@Res() res: Response, @Body() dto: KeyHandoverDto): Promise<void> {
|
async generatePdf(@Res() res: Response, @Body() dto: KeyHandoverDto): Promise<void> {
|
||||||
const pdfBuffer = await this.pdfService.generatePdf(dto);
|
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);
|
res.send(pdfBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,22 +4,26 @@ import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MinioService {
|
export class MinioService {
|
||||||
private readonly client: S3Client;
|
private client: S3Client;
|
||||||
|
|
||||||
constructor(private configService: ConfigService) {
|
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> {
|
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(
|
await this.client.send(
|
||||||
new PutObjectCommand({
|
new PutObjectCommand({
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
|
|||||||
Reference in New Issue
Block a user