mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-01-31 20:51:17 +00:00
MediaController: Use MediaService
to store media
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
c0cbcc863a
commit
e2b5acaf84
2 changed files with 19 additions and 3 deletions
|
@ -6,16 +6,30 @@ import {
|
|||
} from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||
import { MediaService } from '../../../media/media.service';
|
||||
import { MulterFile } from '../../../media/multer-file.interface';
|
||||
|
||||
@Controller('media')
|
||||
export class MediaController {
|
||||
constructor(private readonly logger: ConsoleLoggerService) {
|
||||
constructor(
|
||||
private readonly logger: ConsoleLoggerService,
|
||||
private mediaService: MediaService,
|
||||
) {
|
||||
this.logger.setContext(MediaController.name);
|
||||
}
|
||||
|
||||
@Post('upload')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
uploadImage(@UploadedFile() file) {
|
||||
this.logger.debug('Recieved file: ' + file);
|
||||
async uploadImage(@UploadedFile() file: MulterFile) {
|
||||
this.logger.debug('Recieved file: ' + file.originalname);
|
||||
//TODO: Get user and note from request
|
||||
const url = await this.mediaService.saveFile(
|
||||
file,
|
||||
'hardcoded',
|
||||
'hardcoded',
|
||||
);
|
||||
return {
|
||||
link: url,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { HistoryModule } from '../../history/history.module';
|
||||
import { LoggerModule } from '../../logger/logger.module';
|
||||
import { MediaModule } from '../../media/media.module';
|
||||
import { MonitoringModule } from '../../monitoring/monitoring.module';
|
||||
import { NotesModule } from '../../notes/notes.module';
|
||||
import { RevisionsModule } from '../../revisions/revisions.module';
|
||||
|
@ -18,6 +19,7 @@ import { MonitoringController } from './monitoring/monitoring.controller';
|
|||
RevisionsModule,
|
||||
MonitoringModule,
|
||||
LoggerModule,
|
||||
MediaModule,
|
||||
],
|
||||
controllers: [
|
||||
MeController,
|
||||
|
|
Loading…
Reference in a new issue