aboutsummaryrefslogtreecommitdiff
path: root/pkg/view/media.go
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-01 17:55:50 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-01 17:55:50 +0200
commit6e84441dab0a2b89869e33d7e89d14189d9b67c0 (patch)
treee015839d495bcfc7619f4efd08f97a1ba603fd82 /pkg/view/media.go
parent3f0dc691e2248cc21edd2e74a62b8f28ce95559e (diff)
downloadlens-6e84441dab0a2b89869e33d7e89d14189d9b67c0.tar.gz
lens-6e84441dab0a2b89869e33d7e89d14189d9b67c0.tar.bz2
lens-6e84441dab0a2b89869e33d7e89d14189d9b67c0.zip
feat: Add thumbnailer
Diffstat (limited to 'pkg/view/media.go')
-rw-r--r--pkg/view/media.go14
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)
}