Artwork reader for Artist
This commit is contained in:
@@ -53,10 +53,13 @@ func (api *Router) getPlaceHolderAvatar(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
id := utils.ParamString(r, "id")
|
||||
size := utils.ParamInt(r, "size", 0)
|
||||
|
||||
imgReader, lastUpdate, err := api.artwork.Get(r.Context(), id, size)
|
||||
imgReader, lastUpdate, err := api.artwork.Get(ctx, id, size)
|
||||
w.Header().Set("cache-control", "public, max-age=315360000")
|
||||
w.Header().Set("last-modified", lastUpdate.Format(time.RFC1123))
|
||||
|
||||
@@ -72,7 +75,10 @@ func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*respons
|
||||
}
|
||||
|
||||
defer imgReader.Close()
|
||||
_, err = io.Copy(w, imgReader)
|
||||
cnt, err := io.Copy(w, imgReader)
|
||||
if err != nil {
|
||||
log.Warn(ctx, "Error sending image", "count", cnt, err)
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user