Get port and upload path from config

Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
This commit is contained in:
David Mehren 2020-10-30 22:35:57 +01:00
parent cbd4684785
commit 0e7845e38f
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 21 additions and 8 deletions

View file

@ -5,6 +5,7 @@
*/
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { promises as fs } from 'fs';
import { join } from 'path';
import { ConsoleLoggerService } from '../../logger/console-logger.service';
@ -13,11 +14,16 @@ import { BackendData } from '../media-upload.entity';
@Injectable()
export class FilesystemBackend implements MediaBackend {
// TODO: Get uploads directory from config
uploadDirectory = './uploads';
constructor(private readonly logger: ConsoleLoggerService) {
constructor(
private readonly logger: ConsoleLoggerService,
private configService: ConfigService,
) {
this.logger.setContext(FilesystemBackend.name);
this.uploadDirectory = configService.get<string>(
'media.backend.filesystem.uploadPath',
);
}
private getFilePath(fileName: string): string {