file attachments - WIP

This commit is contained in:
Philipinho
2024-01-08 09:56:10 +01:00
parent e594074fda
commit e1bb2632b8
27 changed files with 616 additions and 49 deletions

View File

@@ -0,0 +1,25 @@
import {
Injectable,
NestInterceptor,
ExecutionContext,
CallHandler,
BadRequestException,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { FastifyRequest } from 'fastify';
@Injectable()
export class AttachmentInterceptor implements NestInterceptor {
public intercept(
context: ExecutionContext,
next: CallHandler,
): Observable<any> {
const req: FastifyRequest = context.switchToHttp().getRequest();
if (!req.isMultipart() || !req.file) {
throw new BadRequestException('Invalid multipart content type');
}
return next.handle();
}
}