Added endpoint to download cover art
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
using Icarus.Constants;
|
||||
using Icarus.Controllers.Utilities;
|
||||
using Icarus.Database.Contexts;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Icarus.Controllers.Managers;
|
||||
using Icarus.Database.Contexts;
|
||||
@@ -78,5 +72,20 @@ public class CoverArtController : BaseController
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("data/download/{id}")]
|
||||
public async Task<IActionResult> Download(int id)
|
||||
{
|
||||
var songContext = new SongContext(_connectionString);
|
||||
var covMgr = new CoverArtManager(this._config);
|
||||
|
||||
var songMetaData = songContext.RetrieveRecord(new Song { SongID = id});
|
||||
var filename = songMetaData.Title + Constants.FileExtensions.JPG_EXTENSION;
|
||||
var c = covMgr.GetCoverArt(songMetaData);
|
||||
|
||||
var data = await c.GetData();
|
||||
|
||||
return File(data, "application/x-msdownload", filename);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user