Implemented getAvatar

This commit is contained in:
Deluan 2016-03-21 20:31:28 -04:00
parent e42ebebe72
commit cdcb5c6f49
4 changed files with 19 additions and 4 deletions

View file

@ -1,22 +1,36 @@
package api
import (
"io"
"os"
"github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/engine"
"github.com/deluan/gosonic/utils"
)
type GetCoverArtController struct {
type MediaRetrievalController struct {
BaseAPIController
cover engine.Cover
}
func (c *GetCoverArtController) Prepare() {
func (c *MediaRetrievalController) Prepare() {
utils.ResolveDependencies(&c.cover)
}
func (c *GetCoverArtController) Get() {
func (c *MediaRetrievalController) GetAvatar() {
var f *os.File
f, err := os.Open("static/itunes.png")
if err != nil {
beego.Error(err, "Image not found")
c.SendError(responses.ERROR_DATA_NOT_FOUND, "Avatar image not found")
}
defer f.Close()
io.Copy(c.Ctx.ResponseWriter, f)
}
func (c *MediaRetrievalController) GetCover() {
id := c.RequiredParamString("id", "id parameter required")
size := c.ParamInt("size", 0)

View file

@ -25,7 +25,8 @@ func mapEndpoints() {
beego.NSRouter("/search2.view", &api.SearchingController{}, "*:Search2"),
beego.NSRouter("/getCoverArt.view", &api.GetCoverArtController{}, "*:Get"),
beego.NSRouter("/getCoverArt.view", &api.MediaRetrievalController{}, "*:GetCover"),
beego.NSRouter("/getAvatar.view", &api.MediaRetrievalController{}, "*:GetAvatar"),
beego.NSRouter("/stream.view", &api.StreamController{}, "*:Stream"),
beego.NSRouter("/download.view", &api.StreamController{}, "*:Download"),

BIN
static/itunes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB