diff options
Diffstat (limited to 'pkg/view')
-rw-r--r-- | pkg/view/media.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/view/media.go b/pkg/view/media.go index ce9e272..0b588f4 100644 --- a/pkg/view/media.go +++ b/pkg/view/media.go @@ -93,9 +93,23 @@ func (self *MediaView) GetImage(ctx *fasthttp.RequestCtx) error { return nil } +func (self *MediaView) GetThumbnail(ctx *fasthttp.RequestCtx) error { + pathHash := string(ctx.FormValue("path_hash")) + + path, err := self.mediaRepository.GetThumbnailPath(ctx, pathHash) + if err != nil { + return self.GetImage(ctx) + } + + ctx.Request.Header.SetContentType("image/jpeg") + fasthttp.ServeFileUncompressed(ctx, path) + return nil +} + func (self *MediaView) SetMyselfIn(r *ext.Router) { r.GET("/media", self.Index) r.POST("/media", self.Index) r.GET("/media/image", self.GetImage) + r.GET("/media/thumbnail", self.GetThumbnail) } |