2025-01-06 08:45:23 +08:00
|
|
|
import {
|
2025-01-27 22:43:31 +08:00
|
|
|
Controller,
|
|
|
|
All,
|
|
|
|
Req,
|
|
|
|
Res,
|
|
|
|
Get,
|
|
|
|
Post,
|
|
|
|
Patch,
|
|
|
|
Param,
|
|
|
|
Delete,
|
|
|
|
Head,
|
|
|
|
Options,
|
2025-04-02 16:14:30 +08:00
|
|
|
NotFoundException,
|
|
|
|
HttpException,
|
|
|
|
HttpStatus,
|
|
|
|
Body,
|
2025-01-06 08:45:23 +08:00
|
|
|
} from '@nestjs/common';
|
2025-01-27 22:43:31 +08:00
|
|
|
import { Request, Response } from 'express';
|
2025-01-06 18:30:16 +08:00
|
|
|
import { TusService } from './tus.service';
|
2025-04-02 16:14:30 +08:00
|
|
|
import { ResourceService } from '@server/models/resource/resource.service';
|
2025-04-02 21:59:19 +08:00
|
|
|
|
|
|
|
interface ResourceMeta {
|
|
|
|
filename: string;
|
|
|
|
filetype: string;
|
|
|
|
filesize: string;
|
|
|
|
}
|
|
|
|
|
2025-01-06 08:45:23 +08:00
|
|
|
@Controller('upload')
|
2025-01-03 09:24:46 +08:00
|
|
|
export class UploadController {
|
2025-04-02 16:14:30 +08:00
|
|
|
constructor(
|
|
|
|
private readonly tusService: TusService,
|
|
|
|
private readonly resourceService: ResourceService,
|
|
|
|
) {}
|
2025-01-27 22:43:31 +08:00
|
|
|
// @Post()
|
|
|
|
// async handlePost(@Req() req: Request, @Res() res: Response) {
|
|
|
|
// return this.tusService.handleTus(req, res);
|
|
|
|
// }
|
2025-01-08 00:52:11 +08:00
|
|
|
|
2025-01-27 22:43:31 +08:00
|
|
|
@Options()
|
|
|
|
async handleOptions(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
2025-01-08 00:52:11 +08:00
|
|
|
|
2025-01-27 22:43:31 +08:00
|
|
|
@Head()
|
|
|
|
async handleHead(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
2025-01-08 00:52:11 +08:00
|
|
|
|
2025-01-27 22:43:31 +08:00
|
|
|
@Post()
|
|
|
|
async handlePost(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
2025-04-22 15:29:39 +08:00
|
|
|
|
2025-01-27 22:43:31 +08:00
|
|
|
@Get('/*')
|
|
|
|
async handleGet(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
2025-01-08 00:52:11 +08:00
|
|
|
|
2025-01-27 22:43:31 +08:00
|
|
|
@Patch('/*')
|
|
|
|
async handlePatch(@Req() req: Request, @Res() res: Response) {
|
|
|
|
return this.tusService.handleTus(req, res);
|
|
|
|
}
|
2025-01-06 08:45:23 +08:00
|
|
|
|
2025-01-27 22:43:31 +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-04-02 16:14:30 +08:00
|
|
|
|
2025-01-27 22:43:31 +08:00
|
|
|
}
|