fix song downloading from gui
This commit is contained in:
@@ -28,7 +28,7 @@ export class TrackController {
|
|||||||
async getFile(@Res({ passthrough: true }) res: Response, @Param('id') id: number): Promise<StreamableFile> {
|
async getFile(@Res({ passthrough: true }) res: Response, @Param('id') id: number): Promise<StreamableFile> {
|
||||||
const track = await this.service.findOne(id);
|
const track = await this.service.findOne(id);
|
||||||
const fileName = `${track.artist} - ${track.song}.${this.configService.get<string>(EnviromentEnum.FORMAT)}`;
|
const fileName = `${track.artist} - ${track.song}.${this.configService.get<string>(EnviromentEnum.FORMAT)}`;
|
||||||
const filePath = createReadStream(resolve(__dirname, '..', this.configService.get<string>(EnviromentEnum.DOWNLOADS_PATH), fileName));
|
const filePath = createReadStream(resolve(__dirname, '..', this.configService.get<string>(EnviromentEnum.DOWNLOADS_PATH), track.playlist.name, fileName));
|
||||||
res.set({'Content-Disposition': `attachment; filename="${fileName}`});
|
res.set({'Content-Disposition': `attachment; filename="${fileName}`});
|
||||||
return new StreamableFile(filePath);
|
return new StreamableFile(filePath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class TrackService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findOne(id: number): Promise<TrackEntity | null> {
|
findOne(id: number): Promise<TrackEntity | null> {
|
||||||
return this.repository.findOneBy({ id });
|
return this.repository.findOne({where: {id}, relations: ['playlist']});
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(id: number): Promise<void> {
|
async remove(id: number): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user