2025-01-06 08:45:23 +08:00
|
|
|
import {
|
|
|
|
Controller,
|
2025-01-06 18:30:16 +08:00
|
|
|
All,
|
|
|
|
Req,
|
|
|
|
Res,
|
|
|
|
Get,
|
2025-01-06 08:45:23 +08:00
|
|
|
Post,
|
2025-01-06 18:30:16 +08:00
|
|
|
Patch,
|
2025-01-06 08:45:23 +08:00
|
|
|
Param,
|
2025-01-06 18:30:16 +08:00
|
|
|
Delete,
|
2025-01-08 00:52:11 +08:00
|
|
|
Head,
|
|
|
|
Options,
|
2025-01-06 08:45:23 +08:00
|
|
|
} from '@nestjs/common';
|
2025-01-06 18:30:16 +08:00
|
|
|
import { Request, Response } from "express"
|
|
|
|
import { TusService } from './tus.service';
|
2025-01-03 09:24:46 +08:00
|
|
|
|
2025-01-06 08:45:23 +08:00
|
|
|
@Controller('upload')
|
2025-01-03 09:24:46 +08:00
|
|
|
export class UploadController {
|
2025-01-06 18:30:16 +08:00
|
|
|
constructor(private readonly tusService: TusService) { }
|
2025-01-08 00:52:11 +08:00
|
|
|
// @Post()
|
|
|
|
// async handlePost(@Req() req: Request, @Res() res: Response) {
|
|
|
|
// return this.tusService.handleTus(req, res);
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Options()
|
|
|
|
async handleOptions(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Head()
|
|
|
|
async handleHead(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
|
|
|
|
2025-01-06 18:30:16 +08:00
|
|
|
@Post()
|
|
|
|
async handlePost(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
2025-01-06 08:45:23 +08:00
|
|
|
}
|
2025-01-08 00:52:11 +08:00
|
|
|
@Get("/*")
|
|
|
|
async handleGet(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
2025-01-06 08:45:23 +08:00
|
|
|
}
|
|
|
|
|
2025-01-08 00:52:11 +08:00
|
|
|
@Patch("/*")
|
|
|
|
async handlePatch(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
2025-01-03 09:24:46 +08:00
|
|
|
}
|
2025-01-06 18:30:16 +08:00
|
|
|
|
2025-01-08 00:52:11 +08:00
|
|
|
// Keeping the catch-all method as a fallback
|
|
|
|
@All()
|
|
|
|
async handleUpload(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
2025-01-03 09:24:46 +08:00
|
|
|
}
|