Add initial methods for file uploading

Implemented placeholders for saving a file in the files service and added a new POST endpoint in the files controller. These changes lay the groundwork for future development of file uploading functionality.
This commit is contained in:
Mathis H (Avnyr) 2024-10-03 12:08:29 +02:00
parent 3eca2472c6
commit addcd4a798
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
2 changed files with 14 additions and 4 deletions

View File

@ -1,16 +1,19 @@
import { Controller, Get, Param, StreamableFile } from '@nestjs/common'; import { Controller, Get, Param, Post, StreamableFile } from '@nestjs/common';
import { FilesService } from "./files.service"; import { FilesService } from "./files.service";
@Controller("files") @Controller("files")
export class FilesController { export class FilesController {
constructor(private readonly filesService: FilesService) {} constructor(private readonly filesService: FilesService) {}
//TODO the file name, replace spaces to underscore and deliver it via the response //TODO POST FILE
@Post('new')
async saveFile() {
}
@Get(':fileId') @Get(':fileId')
async getFile(@Param('fileId') fileId: string) { async getFile(@Param('fileId') fileId: string) {
return this.filesService.get(fileId); return this.filesService.get(fileId);
} }
//TODO POST FILE
} }

View File

@ -54,4 +54,11 @@ export class FilesService {
disposition: `attachment; filename="${fileNameWithoutSpaces}.${fileInformation.fileType.ext.toLowerCase()}"` disposition: `attachment; filename="${fileNameWithoutSpaces}.${fileInformation.fileType.ext.toLowerCase()}"`
}); });
} }
//TODO list the files
//TODO save a file
public async set() {
}
} }